Reputation: 1119
i'm developing an application using Netbeans RCP. I have added an option to add a jar to my class path in the project.properties
file of my platform:
run.args.extra=-cp:a ./appclient/glassfish/lib/gf-client.jar
The problem i encounter is that is does work when i run it from the Netbeans IDE but not when i try to create a independent application (build for Mac OSX for instance). I hear that the project.properties
is no longer taken in account when you run an independent application and of course my appclient
directory containing the jars does not exist anymore in the application package (so my jar is not added to class path).
How can i make this -cp option works for my independent Mac OSX application?
EDIT: i was able to create a custom conf file for my independent platform but i can't find a way to add my jar to the class path, i don't know what options to use.
EDIT: i found that i need to you endorsed mechanism to achieve it. So i have added the following command to my app.conf file:
J-Djava.endorsed.dirs=/Users/altanis/appclient/glassfish/lib/gf-client.jar
But when i run the .app (mac application), i get this error:
-J-Djava.endorsed.dirs=/Users/altanis/appclient/glassfish/lib/gf-client.jar: No such file or directory
The path is correct. Do i need to make something special to make the JVM aware of this? I followed this tutorial and somewhere in the comments the author says:
Right, but the package-appclient copies everything for you and you should be able to put it on the classpath using the endorsed mechanism. Unpack the jar created by that and add everything you need from there (the jars) to your application installer. Then you can use the endorsed (-J-Djava.endorsed.dirs=${GFCLIENT_PATH}) mechanism in your app.conf to put it on the application classpath. This way you should be able to deploy it together with your client.
Upvotes: 1
Views: 554
Reputation: 2173
I think, that create a new library is the better way.
Upvotes: 1
Reputation: 29673
You must add entry Class-path
to you application's MANIFEST.MF
For example
Class-Path: apache-commons-2.1.jar ejb-api-3.0.jar
all this jars
should be in the root directory of your application
Your appliction should have next structure
MyApplication.jar
/META-INF
/META-INF/MANIFEST.MF
/apache-commons-2.1.jar
/ejb-api-3.0.jar
/com/package/classes
or you can use jar
tool of JDK to create a jar
read more here Oracle doc
Upvotes: 0