• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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
 
I will suppress my every urge. But not this shameless plug:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic