Help coderanch get a
new server
by contributing to the fundraiser
  • 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

Executing jar - when java -jar fails

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good day!

I'm developing a windows small application. This application sometimes needs to run second java application (update mechanism) - it downloads it from specified url and executes (java -jar downloaded.jar). And here my problem starts.

Today I saw a Windows 7 computer, where java was able (I double-clicked jar file, program executed), but there was no java command ('java -version' gave 'java command not found' error). I just need to execute an jar on every enviroment (before I thought 'java -jar blabla.jar solves all problems). The question is:

How to execute a jar from app(may be batch command - I run it from java code)? Should I execute 'java -jar blabla.jar' and if that failes try 'start blabla.jar' or something? I don't know any paths, I need a generic solution. I don't want to make any panalty instalations, change any system registers. Thank you for the help!
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All jar files aren't executable.
 
Krzysztof Mroczek
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jar files aren't executable, however it may be executed with jre. Operating on computer I saw was able somehowe to run them with a jre when double-clicking the jar file in file manager, but command java -version on command prompt was illegal.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. File associations are independent of the PATH environment variable.
2. The default executable associated with jar files is javaw.exe, not java.exe
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic