This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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: 167
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: 20080
    
  30

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 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 167
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: 167
This instructions for netbeans (packing all libraries into single jar) worked for me
webpage
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: jar not ok when in different folder
 
It's not a secret anymore!