File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Question about runnable JARs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Question about runnable JARs" Watch "Question about runnable JARs" New topic

Question about runnable JARs

Silly Pants

Joined: Nov 20, 2011
Posts: 1
I have written some small programs and I am attempting to make my first runnable JAR file. The program will run fine within Netbeans and Eclipse. However, when I create my runnable JAR, the resultant JAR gives me an error saying that the program can't find my main class when I try and execute it. What I don't understand is how the compiler can find my main class to compile the program and yet the final executable code can't find it to run it? Is there some file I can open up and type my class locations into by hand?

Also, on a related not, I was hoping someone might be able to help me with something. So far, the books I have found about Java programming only talk about coding and not a lot about how to configure my settings in the IDE (which consume about 95% of my time spent on the subject). So far, I like coding and grinding out a solution in code and feel that I haven't struggled nearly as much on the material in the books I've worked through as I have on battling with configurations and IDE settings and such, yet I find it a lot easier to find reading material and instructional posts about coding than I do about the more difficult issues.

Can anoyone here recommend any good books on Eclipse or Netbeans?
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 445

You would need to have a Manifest file with the following detail:

And then you can execute it using the command:


Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46405
Welcome to the Ranch

If you are new to Java™, you would do better to forget IDEs and get a decent text editor (eg gedit, NotePad2, NotePad++). Set its options to automatic indentation (change 1 tab to 4 spaces), bracket and syntax highlighting. Use that to edit your Java™ text and run it from the command line. That way you won’t spend 95% of your time on the IDE.
I agree. Here's the link:
subject: Question about runnable JARs
It's not a secret anymore!