Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JVM for jar

 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I find which JVM is being used for a jar file?

Please help.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got you. Thanks!
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java -version
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic