Oh sorry it is fine now: it's just because there is no output to print
with the last script "print("code sample") ", after deleting it, the
jar is working fine.
Thanks again.

If somebody else will need more information, the steps to compile this
project were:

Easy AOT Compile with Netbeans&Maven

1- Install Maven and Enclojure (in my case)

2- Create a new clojure project

3- In sources create a new clojure file like the above, putting
(ns com.yourcompany.defpackage(:gen-class)) ... at the beginning of
the clj file.

4- Add Assembly Plugin in the POM file specifying the package of the
main clojure file, something like this:
...
<plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2.2</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
           <archive>
            <manifest>
              <mainClass>com.yourcompany.defpackage</mainClass>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> <!-- this is used for inheritance
merges -->
            <phase>package</phase> <!-- bind to the packaging phase --
>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
...

5- Build the project (with Netbeans just right click on the project)

6- Done



On Dec 8, 12:42 am, Riccardo <riccardo.novie...@gmail.com> wrote:
> Right I am finally getting closer: the generated jar finally works,
> but it still gives a message "A java exception has occurred"
>
> My code (not really mine...) look like this:
> -----------------------------------------------------------------------------------------------------
> (ns com.yourcompany.defpackage
>         (:gen-class))
>
> (import '(javax.swing JFrame JButton JOptionPane)) ;'
> (import '(java.awt.event ActionListener))          ;'
>
> (let [frame (JFrame. "Hello Swing")
>      button (JButton. "Click Me")]
>  (.addActionListener button
>    (proxy [ActionListener] []
>      (actionPerformed [evt]
>        (JOptionPane/showMessageDialog  nil,
>           (str "<html>Hello from <b>Clojure</b>. Button "
>                (.getActionCommand evt) " clicked.")))))
>
>  (.. frame getContentPane (add button))
>
>  (doto frame
>    (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
>    .pack
>    (.setVisible true)))
>
> print("code sample")
>
> -----------------------------------------------------------------------------------------------------
>
> The POM file is this:
>
> ---------------------------------------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>   
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd";>
> <properties>
>         <clojure.version>1.2.0</clojure.version>
> </properties>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>org.enclojure</groupId>
>   <artifactId>sample</artifactId>
>   <version>0.0.1</version>
>   <name>Banking_Clojure</name>
>   <description>Banking_Clojure</description>
>   <build>
>      <sourceDirectory>src/main/clojure</sourceDirectory>
>      <testSourceDirectory>src/test/clojure</testSourceDirectory>
>         <resources>
>             <resource>
>                 <directory>src/main/clojure</directory>
>             </resource>
>             <resource>
>                 <directory>src/main/resources</directory>
>             </resource>
>         </resources>
>         <testResources>
>             <testResource>
>                 <directory>src/test/clojure</directory>
>             </testResource>
>         </testResources>
>     <plugins>
>       <plugin>
>         <groupId>com.theoryinpractise</groupId>
>         <artifactId>clojure-maven-plugin</artifactId>
>         <version>1.3.2</version>
>         <configuration>
>             <sourceDirectories>
>                 <sourceDirectory>src/main/clojure</sourceDirectory>
>             </sourceDirectories>
>             <clojureOptions>-Xmx1G</clojureOptions>
>         </configuration>
>         <executions>
>           <execution>
>             <id>compile-clojure</id>
>             <phase>compile</phase>
>             <goals>
>               <goal>compile</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <source>1.6</source>
>           <target>1.6</target>
>         </configuration>
>       </plugin>
>
>        <plugin>
>         <artifactId>maven-assembly-plugin</artifactId>
>         <version>2.2.2</version>
>         <configuration>
>           <descriptorRefs>
>             <descriptorRef>jar-with-dependencies</descriptorRef>
>           </descriptorRefs>
>            <archive>
>             <manifest>
>               <mainClass>com.yourcompany.defpackage</mainClass>
>             </manifest>
>           </archive>
>         </configuration>
>         <executions>
>           <execution>
>             <id>make-assembly</id> <!-- this is used for inheritance
> merges -->
>             <phase>package</phase> <!-- bind to the packaging phase --
>
>             <goals>
>               <goal>single</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>
>     </plugins>
>   </build>
>   <repositories>
>     <repository>
>       <id>central</id>
>       <url>http://repo1.maven.org/maven2</url>
>     </repository>
>     <repository>
>       <id>clojure-releases</id>
>       <url>http://build.clojure.org/releases</url>
>     </repository>
>     <repository>
>       <id>incanter</id>
>       <url>http://repo.incanter.org</url>
>     </repository>
>     <repository>
>       <id>clojure-snapshots</id>
>       <url>http://build.clojure.org/snapshots</url>
>     </repository>
>     <repository>
>       <id>clojars</id>
>       <url>http://clojars.org/repo/</url>
>     </repository>
>   </repositories>
>   <dependencies>
>   <dependency>
>     <groupId>org.clojure</groupId>
>     <artifactId>clojure</artifactId>
>     <version>${clojure.version}</version>
>   </dependency>
>   <dependency>
>     <groupId>org.clojure</groupId>
>     <artifactId>clojure-contrib</artifactId>
>     <version>${clojure.version}</version>
>   </dependency>
>     <dependency>
>       <groupId>swank-clojure</groupId>
>       <artifactId>swank-clojure</artifactId>
>       <version>1.2.1</version>
>         <exclusions>
>           <exclusion>
>             <groupId>org.clojure</groupId>
>             <artifactId>clojure</artifactId>
>           </exclusion>
>           <exclusion>
>             <groupId>org.clojure</groupId>
>             <artifactId>clojure-contrib</artifactId>
>           </exclusion>
>         </exclusions>
>     </dependency>
>   </dependencies>
> </project>
>
> -------------------------------------------------------------------------------------
>
> Many thanks to everybody for the attention.
> I hope to be able to contribute to the clojure group soon...
> Thanks again
>
> Riccardo
> (Swansea University, UK)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to