Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Netbeans jars versus Eclipse jars

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I usually use eclipse, and when I export a J2SE project, I get a jar file which I can simply double click to run it.

With netbeans 6.8, I do same thing (clean and build), then in the dist folder, theres also a jar.
When I try to run it, nothing happens. But if I drop the file onto ExecutorDemo, to make an exe, it then works (as it does with eclipses' jars).
But it doesn't work just as jar, and the actual jar size with netbeans is much bigger than with eclipse, even when compression is applied.

Can anyone tell me why netbeans jars dont run when double clicked, thanks.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you examined the contents of the JAR file, including the contents of the manifest.mf files, to determine the difference? Another thing to try is running the JAR file the command line:

java -jar fromnetbean.jar

Then if there are any error they will be printed to stdout.

Most likely, the manifest.mf file in the JAR that NetBeans built is missing the Main-Class entry.

(The above are debugging suggestions and a guess - I never let NetBeans or Eclipse compile or package apps, that job I delegate to Maven or Ant).
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's a NetBeans project, you need to specify the Main class in the project properties. NetBeans will then create a MANIFEST.MF that will contain the Main-Class entry.

Afterwards, you can simply double click the JAR (if you're in Windows) or run it in the command line via java -jar yourjar.jar

Hope it helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic