permaculture playing cards*
The moose likes Java in General and the fly likes jar not ok when in different folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar not ok when in different folder" Watch "jar not ok when in different folder" New topic
Author

jar not ok when in different folder

Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 147
1.compile my app
2. dist folder, doble click jar --> all goes OK
3.Copy jar to some other folder -> run it --> JVM error - could not find main class forms.MyForm ?


Searchable nature photo gallery: http://agrozoo.net/jsp/Galery.jsp?l2=en
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

Check out the MANIFEST.MF file inside the JAR file (use a ZIP tool to open the JAR). Check out what the Class-Path is. That's relative to the JAR file itself. I think you copied the JAR file but forgot to copy some of the JAR files it needs.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 147
you were right, I kind of expected that clean & build wraps all into one jar.
Or at least in NetBeans I would expect a checkbox to do that ...

can you recomend a toll for wrapping all, main yar + all libraries into one jar.

I read somewhere that this can be done with proguard, but I have no luck with it.
Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 147
This instructions for netbeans (packing all libraries into single jar) worked for me
webpage
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jar not ok when in different folder
 
Similar Threads
wars and classpath ?
applet writing
Trying to execute java program which is in jar file
Class Loader
Package problem