• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jar file

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

i've created a jar file, it runs from the command line but when i double click on it , it won't run.
what can i do? how do i find out whats wrong?

thanks
 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming you are on Windows, the type of file is determined by its extension (.jar in this case), and you can designate a program to 'open' (execute, in this case) a file with that extension when you double-click it. On Windows Explorer (not Internet Explorer), under "Tools / Folder Options / File Types" is a (long) list of file types and buttons and so forth to change and set their associated programs. For .jar files, mine is set to the "Java(TM) Platform SE binary". I expect you should set it to your "java.exe", but it was done so long ago on my machine I don't remember. And it might be done by some sort of installation of the JRE, I don't remember that either.

 
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to make your jar executable by adding a manifest file that specifies your main class.
http://introcs.cs.princeton.edu/java/85application/jar/jar.html

And yes, make sure that java.exe is the process that gets called.
I recently updated one of the apps on my computer that put itself as the default executor of jar files. Imagine my surprise when I double-clicked on a jar and a seemingly un-related app popped up.

You should be able to see the error by opening a command prompt and typing "<yourprogram>.jar" (note, no java command).
 
Mary Murphy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you !

however i have only just realised the reason it wasn't working was because i only had system.out statements in it, by putting a JOptionpane i was able to see that double clicking works.

i feel fairly silly as i wasted loads of time trying to work out what was wrong!
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

You didn’t waste lots of time. You learnt an important lesson about opening .jars by different techniques and about Consoles. That will enable you to avoid null pointer exceptions next time you use a Console object.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic