• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Detecting JRE

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure about this topic should be part of this form or not. But Still its related to java.
I have to write a shell script in java that will detect JRE and then start executing application bundled as jar file. Thanks in advance
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't write shell scripts in Java.

If the user's environment is set up properly, you don't need to do complicated things to detect the JRE. Just run the application with:

java -jar TheJarFile.jar
 
Rajendra Gangarde
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I mean to say I have to write shell script in linux,
Which will
1) detect JRE is installed.
2) then check that required libraries are installed
if not then displays error message or else continue application bundled as jar file.
Hope this makes my question more clear
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to check the version of JRE then use
System.getProperty("java.version") .

But if you want to check whether JRE is installed or not, this will not help you.

If you are getting ClassNotFound exception, you can say required library is missing.

But better way to do this would be getting jar list using

System.getProperty("java.class.path");
// Check your .jar files are there or not.

System.getProperty("java.library.path");
//Get list of files from the
resultant path and check your .jar files are there or not.

[ September 02, 2005: Message edited by: Chetan Parekh ]
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if it helps:

jrePresent=ls -1 `which java` | wc -l

if [ $jrePresent = 1 ]

jreBinDirectory=dirname `which java`
jreLibDirectory=$jreBinDirectory/../lib
.....
.....

fi
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic