trouble packaging jars

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

trouble packaging jars

mikel evins
I'm using Kawa to write a networked 3D game built on JavaMonkeyEngine. The combination works great. It performs extremely well, and enables us to add and modify features extremely rapidly with very compact code.

Now I want to figure out how to package our classes in executable jars. That's turning out to be more difficult than I anticipated. I've been unable to get the kawac ant task to work outside of the kawa sources. I've tried using plain old Makefiles and using kawa as a compiler, which works fine, but for some reason I end up unable to figure out the right class or classpath to put in the manifest.

Is anyone else doing interactive development with Kawa and then building the results into a standalone jar? If so, I'd love to pick your brain about how you set up the jar builds. So far, examining kawa's own buildfile and sources has not helped the light dawn.

I suppose I should mention I'm not exactly new to doing this. I've packaged executable jars many times before from sources in several different languages--Java, Scala, Clojure, and even--ten years or so ago--Kawa itself. However, it has been a couple of years since the last time, so there's a good likelihood that I'm just forgetting something simple.

I don't want to spew tons of details about all the stuff I've tried so far--your eyes would glaze over--but, just briefly, the project consists of a set of library jars (including kawa itself), and the Scheme sources of the game client and server. We use Emacs to run kawa, and we run the game processes from the repl. This enabls us to inspect and interact with the game server and client in real time, while they're running. Kawa's performance is great for this stuff; we can go from a cold start to a running game client in a couple of seconds; we can change meshes, lighting, animation, and whatever in real time while the game runs; we can kill the client or server, change something, and be back in the game in a couple of seconds.

Very briefly, I've tried using the kawac ant task, but I can't seem to figure out how to use it outside kawa's source tree. I can point it at kawa's tools directory and then ant can find the definition of the Kawac class, but then it complains that it can't find kawa.repl, and nothing I've tried (i.e. all sorts of path-like structures pointing to where the kawa jar is) fixes that problem.

I've tried running kawa from a Makefile to compile the scheme sources to classfiles, and that works well enough, but then I can't seem to figure out a way to package them with a manifest so that java can find the main class. Yes, I compiled with kawa --main, and yes, when I jar ft the jarfile, the main class is where the manifest says it is, but java complains just the same that it can't find od load the class.

Thanks in advance for any help or advice.


Reply | Threaded
Open this post in threaded view
|

Re: trouble packaging jars

Alcides Flores Pineda
Hello Mikel

I've written a little demo & proof of concept application here:
- https://github.com/alcidesfp/swing-kawa
to teach myself howto compile and create distributable jars with Kawa.
Its a basic ("Hello World") GUI (Swing) application.

Maybe the build.xml and the scripts there can help you and/or give you
some ideas.

Greetings.
--
Alcides Flores Pineda.

On Tue, May 06 2014, mikel evins wrote:

> I'm using Kawa to write a networked 3D game built on JavaMonkeyEngine. The
> combination works great. It performs extremely well, and enables us to add
> and modify features extremely rapidly with very compact code.
>
> Now I want to figure out how to package our classes in executable
> jars. That's turning out to be more difficult than I anticipated. I've
> been unable to get the kawac ant task to work outside of the kawa
> sources. I've tried using plain old Makefiles and using kawa as a
> compiler, which works fine, but for some reason I end up unable to figure
> out the right class or classpath to put in the manifest.
>
> Is anyone else doing interactive development with Kawa and then building
> the results into a standalone jar? If so, I'd love to pick your brain
> about how you set up the jar builds. So far, examining kawa's own
> buildfile and sources has not helped the light dawn.
>
> I suppose I should mention I'm not exactly new to doing this. I've
> packaged executable jars many times before from sources in several
> different languages--Java, Scala, Clojure, and even--ten years or so
> ago--Kawa itself. However, it has been a couple of years since the last
> time, so there's a good likelihood that I'm just forgetting something
> simple.
>
> I don't want to spew tons of details about all the stuff I've tried so
> far--your eyes would glaze over--but, just briefly, the project consists
> of a set of library jars (including kawa itself), and the Scheme sources
> of the game client and server. We use Emacs to run kawa, and we run the
> game processes from the repl. This enabls us to inspect and interact with
> the game server and client in real time, while they're running. Kawa's
> performance is great for this stuff; we can go from a cold start to a
> running game client in a couple of seconds; we can change meshes,
> lighting, animation, and whatever in real time while the game runs; we can
> kill the client or server, change something, and be back in the game in a
> couple of seconds.
>
> Very briefly, I've tried using the kawac ant task, but I can't seem to
> figure out how to use it outside kawa's source tree. I can point it at
> kawa's tools directory and then ant can find the definition of the Kawac
> class, but then it complains that it can't find kawa.repl, and nothing
> I've tried (i.e. all sorts of path-like structures pointing to where the
> kawa jar is) fixes that problem.
>
> I've tried running kawa from a Makefile to compile the scheme sources to
> classfiles, and that works well enough, but then I can't seem to figure
> out a way to package them with a manifest so that java can find the main
> class. Yes, I compiled with kawa --main, and yes, when I jar ft the
> jarfile, the main class is where the manifest says it is, but java
> complains just the same that it can't find od load the class.
>
> Thanks in advance for any help or advice.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: trouble packaging jars

mikel evins

On May 6, 2014, at 3:56 PM, Alcides Flores Pineda <[hidden email]> wrote:

> Hello Mikel
>
> I've written a little demo & proof of concept application here:
> - https://github.com/alcidesfp/swing-kawa
> to teach myself howto compile and create distributable jars with Kawa.
> Its a basic ("Hello World") GUI (Swing) application.
>
> Maybe the build.xml and the scripts there can help you and/or give you
> some ideas.

Thanks very much! That's just what I was hoping for. With luck, I can use it to figure out where I went wrong.

--me


Reply | Threaded
Open this post in threaded view
|

Re: trouble packaging jars

mikel evins
In reply to this post by Alcides Flores Pineda

On May 6, 2014, at 3:56 PM, Alcides Flores Pineda <[hidden email]> wrote:

> I've written a little demo & proof of concept application here:
> - https://github.com/alcidesfp/swing-kawa
> to teach myself howto compile and create distributable jars with Kawa.
> Its a basic ("Hello World") GUI (Swing) application.
>
> Maybe the build.xml and the scripts there can help you and/or give you
> some ideas.

Woops. The build fails:

$ ant
Buildfile: /Volumes/ymra/Attic/Software/Languages/Scheme/kawa/swing-kawa/build.xml

BUILD FAILED
/Volumes/ymra/Attic/Software/Languages/Scheme/kawa/swing-kawa/build.xml:37: The entity name must immediately follow the '&' in the entity reference.

Total time: 0 seconds

So I found and fixed the ampersand and tried again. I see the same problem I've been having:

$ ant
Buildfile: /Volumes/ymra/Attic/Software/Languages/Scheme/kawa/swing-kawa/build.xml

gui:
    [javac] Compiling 1 source file
     [kawa] Error: Could not find or load main class kawa.repl

BUILD FAILED
/Volumes/ymra/Attic/Software/Languages/Scheme/kawa/swing-kawa/build.xml:44: Java returned: 1

Total time: 0 seconds


If your buildfile is really working, it suggests that I may have some local configuration issue. What version of ant and of the JDK are you using?


Reply | Threaded
Open this post in threaded view
|

Re: trouble packaging jars

Alcides Flores Pineda
Hi.

I've corrected the "&" error (recently introduced)
You need to have the kawa JAR (v.gr: kawa-1.14.jar) renamed or symlinked
to kawa.jar in the lib directory for the build to run as is, otherwise
you need to edit the build.xml to use the
- path/name/of/your/kawa-version.jar

I forgot to put that in the README (its updated now)

With this in place, the build runs fine.
I've just run & tested it using kawa-1.14 and java 7 (1.7.0_25)

> ~/Projects/afp/swing-kawa-master$ ant
> Buildfile: /Users/devel/Projects/afp/swing-kawa-master/build.xml
>  
> gui:
>      [kawa] (compiling gui/MyApp.scm to gui.MyApp)
>  
> src:
>      [kawa] (compiling main.scm to main)
>  
> BUILD SUCCESSFUL
> Total time: 2 seconds

I hope this helps
--
Alcides Flores Pineda

On Tue, May 06 2014, mikel evins wrote:

> On May 6, 2014, at 3:56 PM, Alcides Flores Pineda <[hidden email]> wrote:
>
>> I've written a little demo & proof of concept application here:
>> - https://github.com/alcidesfp/swing-kawa
>> to teach myself howto compile and create distributable jars with Kawa.
>> Its a basic ("Hello World") GUI (Swing) application.
>>
>> Maybe the build.xml and the scripts there can help you and/or give you
>> some ideas.
>
> Woops. The build fails:
>
> $ ant
> Buildfile: /Volumes/ymra/Attic/Software/Languages/Scheme/kawa/swing-kawa/build.xml
>
> BUILD FAILED
> /Volumes/ymra/Attic/Software/Languages/Scheme/kawa/swing-kawa/build.xml:37: The entity name must immediately follow the '&' in the entity reference.
>
> Total time: 0 seconds
>
> So I found and fixed the ampersand and tried again. I see the same problem I've been having:
>
> $ ant
> Buildfile: /Volumes/ymra/Attic/Software/Languages/Scheme/kawa/swing-kawa/build.xml
>
> gui:
>     [javac] Compiling 1 source file
>      [kawa] Error: Could not find or load main class kawa.repl
>
> BUILD FAILED
> /Volumes/ymra/Attic/Software/Languages/Scheme/kawa/swing-kawa/build.xml:44: Java returned: 1
>
> Total time: 0 seconds
>
>
> If your buildfile is really working, it suggests that I may have some local configuration issue. What version of ant and of the JDK are you using?
>
>