Jump to content
Excelsior Forums
ajvpr

Question about classpath in JET

Recommended Posts

I am working on an application that is being built with JET and I'm having trouble adding an item to the classpath.

I have a zip file (audio.zip) that contains audio resources that I want to pass through the classpath. The important detail is that this file must be separate from the executable. So this would be an add-on to the program after it is installed. This file, if present, would be at the application's install directory in Windows.

Through our regular building methods (just building a JAR), I could just pass the name of the zip file as a classpath argument and it would not complain about not having it available.

When I try to do this with JET, it always complains that the zip file is not available when trying to build the project. I have tried to specify that this is an external zip file/resource that will be provided outside the .EXE but the build still fails. Here is what my classpath directive looks like:

!classpathentry audio.zip

-pack=none

-protect=nomatter

-optimize=autodetect

!end

Any ideas how I can make this work?

Share this post


Link to post
Share on other sites

Hello,

Please try to remove the classpath directive for audio.zip from your project,

then build and deploy the application.

If you then simply put the file to the same directory where deployed application executable is located,

the application should find it.

Please let us know the results.

Share this post


Link to post
Share on other sites

Hello,

Please try to remove the classpath directive for audio.zip from your project,

then build and deploy the application.

If you then simply put the file to the same directory where deployed application executable is located,

the application should find it.

Please let us know the results.

If I do this I would have no way of accessing the audio zip file. I need to have it in the classpath so it will load the resource (the zip file) to my application's working directory. This is the way I'm calling the audio files inside the zip file:

InputStream mis = getClass().getClassLoader().getResourceAsStream( "audioFile1.wav" );

If my audio.zip is loaded in the classpath this call should work no problem.

Share this post


Link to post
Share on other sites

Then you can do this by explicitly specifying classpath for deployed application before launching it by using environment variable JETVMPROP.

You should add "-Djava.class.path=<classpath>" to it, where <classpath> should be replaced by classpath which your deployed application uses including path to audio.zip.

For example:

set JETVMPROP="-Djava.class.path=.\resources\audio.zip"
App.exe

Please try to do this and let us know if it helps.

Share this post


Link to post
Share on other sites

That was it! I actually read on some other forum about using that variable but I had no clue of how to properly specify the classpath in there. Everything is now working correctly.

Like you said, I did have to include as well the other items that were in my application's classpath for it to work normally.

Thanks!

Share this post


Link to post
Share on other sites

You are welcome!

Also, this method requires to create a batch script, so it may be inconvenient.

Here are the alternatives:

1) You can build your application with fake empty audio.zip file, opting not to pack it in executable in JET Control Panel,

then add it to the installation package on "Resources" page of JetPack II. So it will be included to the classpath.

After installation the fake empty archive can be replaced by the real one.

2) You can create multi-app executable by choosing the corresponding option on the "Target" page of JET Control Panel.

This executable may take "java.class.path" property from its arguments.

So then in JetPack II you can choose corresponding application shortcut on tab "Shortcuts" on page "Misc"

and specify application classpath by adding "-Djava.class.path=<classpath>" to its arguments.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×