• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Detecting JRE  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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 is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!