File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes JVM for jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JVM for jar" Watch "JVM for jar" New topic
Author

JVM for jar

Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
How do I find which JVM is being used for a jar file?

Please help.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Define "which JVM." JVM version, or path to the executable? If it's the former, just check the "java.version" system property. If it's the latter, you may be able to use Class.getResource() to get a file:// URL for a System class file, then examine the URL for a local path.


[Jess in Action][AskingGoodQuestions]
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
The system I am wokring on may be having multiple versions of JVM. SO I guess to find version I will have to go second route you pointed.
This might be bigginer question, Can you eloborate how do I use Class.getResource?
I have .jar files in a directory and I want to find which JVM each one is using.

Thanks for your reponse
Gemini
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Originally posted by Gemini Moses:

I have .jar files in a directory and I want to find which JVM each one is using.


Nothing about a jar file itself will tell your computer what JVM to use; it depends only and entirely on your computer's settings. If we're talking about a jar file you double-click to execute, then you need to look at the OS's file association for jar files, and possibly (if the association doesn't specify a path) your PATH environment variable to see which version of "java" is first on the path.

Is that all you're asking?
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Got you. Thanks!
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

java -version
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JVM for jar