This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- java version check!!
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 01, 2009
06:30 AM
java version check!!
Hi all,
Suppose on computer 4 different versions of java are installed.
(1) Depending on the path of java.exe we can open command prompt go to path /jdk_version/bin/java.exe and type "java -version" and know the
particular version, But we cant extract the output of the command "java -version" into a file.
(2) Also using System.getProperty("java.lversion"); in java code we can get java version but it will return the version of the jvm that is running that
program. Or the path set to environment variable JAVA_HOME.
(3) Also following code can be used but it's not working:!!!(don't know why??)
import java.io.*;
import java.lang.*;
public class x
{
public static void main (String args[])
{
try
{
// get runtime environment and execute child process
Runtime systemShell = Runtime.getRuntime();
Process output = systemShell.exec("java -version");
// open reader to get output from process
BufferedReader br = new BufferedReader (new InputStreamReader(output.getInputStream()));
String line = null;
System.out.println("");
while((line = br.readLine()) != null )
{ System.out.println(line); } // display process output
System.out.println("");
int exitVal = output.waitFor(); // get process exit value
System.out.println("Process Exit Value : "+ exitVal);
}
catch (IOException ioe){ System.err.println(ioe); }
catch (Throwable t) { t.printStackTrace();}
}
}
*** My requirement is :***
4 or more jdk are installed on OS. depending on path of java.exe I need to find it's version.
Can anybody help please?????
Thanks in advance,
Nilesh Rathod.
Suppose on computer 4 different versions of java are installed.
(1) Depending on the path of java.exe we can open command prompt go to path /jdk_version/bin/java.exe and type "java -version" and know the
particular version, But we cant extract the output of the command "java -version" into a file.
(2) Also using System.getProperty("java.lversion"); in java code we can get java version but it will return the version of the jvm that is running that
program. Or the path set to environment variable JAVA_HOME.
(3) Also following code can be used but it's not working:!!!(don't know why??)
import java.io.*;
import java.lang.*;
public class x
{
public static void main (String args[])
{
try
{
// get runtime environment and execute child process
Runtime systemShell = Runtime.getRuntime();
Process output = systemShell.exec("java -version");
// open reader to get output from process
BufferedReader br = new BufferedReader (new InputStreamReader(output.getInputStream()));
String line = null;
System.out.println("");
while((line = br.readLine()) != null )
{ System.out.println(line); } // display process output
System.out.println("");
int exitVal = output.waitFor(); // get process exit value
System.out.println("Process Exit Value : "+ exitVal);
}
catch (IOException ioe){ System.err.println(ioe); }
catch (Throwable t) { t.printStackTrace();}
}
}
*** My requirement is :***
4 or more jdk are installed on OS. depending on path of java.exe I need to find it's version.
Can anybody help please?????
Thanks in advance,
Nilesh Rathod.
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 01, 2009
09:33 AM
I suspect you need to check existing JDKs in order to know which one to use. The simple and elegant solution would be to bundle the correct version of JVM, thus insuring your setup and application will run no matter the platform (even on those which don't have installed JVMs / JDKs).
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 02, 2009
01:13 AM
pv7721 wrote:
I suspect you need to check existing JDKs in order to know which one to use. The simple and elegant solution would be to bundle the correct version of JVM, thus insuring your setup and application will run no matter the platform (even on those which don't have installed JVMs / JDKs).
Actually my requirement is list the installed jdk (only jdk not jre) and know the version of selected jdk. I am going to bundle jdk too but also have to give the functinality if user wants to use installed jdk. But version of the jdk should be 1.5.0_15 or higher.
So I need to check the version of selected jdk.
Can you help please??
Thanks in advance,
Nilesh Rathod.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 02, 2009
06:35 AM
pv7721 wrote:
I suspect you need to check existing JDKs in order to know which one to use. The simple and elegant solution would be to bundle the correct version of JVM, thus insuring your setup and application will run no matter the platform (even on those which don't have installed JVMs / JDKs).
What about this issue ?????
Thanks in advance,
Nilesh Rathod.
