• Post Reply Bookmark Topic Watch Topic
  • New Topic

executable jar file  RSS feed

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I make an executable jar file that requires classes in another jar file? I tried putting the second one in the first one but I'm getting an error when I try to run it. Also I tried using the "Class-Path:" to specify a relative path to the other jar but that doesn't seem to work either.

Chris
 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried one more thing...

I extracted the second jar and then rebuilt one new jar with all the classes in their packages. Now I can run it with

java -jar myApp.jar

But, if I double click on the .jar, I get an error. "Fatal exception occured" on the Virtual Machine launcher. All that I can tell is that the program associated with .jar files is javaw instead of java.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you discovered, it doesn't work to have a JAR inside a JAR - the internal JAR isn't accessible.

Since you can run the JAR with the command java -jar MyJar.jar but not while double-clicking on it indicates an operating system configuration problem. You might have success in correcting the problem by manually editing your file association setting for .jar files. Mine is set to

"F:\Program Files\Java\jre1.5.0\bin\javaw.exe" -jar "%1" %*

with "Use DDE" selected.

The easiest thing to do might be to simply uninstall every trace of Java, restart, then install whatever versions of Java you want, always installing the newest version last. Don't forget to set the PATH, JAVA_HOME and CLASSPATH environment variables as appropriate.
[ September 25, 2004: Message edited by: Dirk Schreckmann ]
 
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks really interesting, but I haven't had the chance to try it yet. It's an open-source project called "One-Jar". It's an application launcher with a custom classloader that can load jars out of jars. You can package one-jar up with your app in a single Jar which includes all the other jars, and everything works. Give it a try and let us know how it works!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!