can I run more than one JVM on my single PC?

前端 未结 7 1066
暖寄归人
暖寄归人 2020-12-14 23:07

Can I run more than one JVM? If yes then how can I find a particular class is loaded on which JVM?

相关标签:
7条回答
  • 2020-12-15 00:08

    Yes, you can run multiple JVM's on a single machine.

    Sun packages the tools to run the jvm in a few different ways. Usually, you either have a java development kit (jdk) or java standard edition (jse) installed as the default. Those packages include a java program that gets invoked to start a jvm. In addition, the jdk also contains some additional commands (like javac) for developers.

    You can have multiple jdk's and or jse's available on a single machine. On windows, jdk and jse packages are usually installed under Program Files/java (this is from memory as I don't have a pc handy at the moment)

    On Mac look under /System/Library/Frameworks/JavaVM.framework/Versions.

    On Linux, I would use which java command to determine where the default java command is installed (usually /usr/bin). Then do a ls -al | grep java (inside /usr/bin, for example) and note where the symlinks point in order to figure out where there might be other versions installed.

    Once you've figured out where each of the various jdk's and jse's are located on your system, then you can start to figure out which version of java is used to start each of the programs.

    Each java program will startup using the default jvm. Open a command window or terminal and try java -version to determine which version is the current default.

    Rather than using the default java version, programs can also be started to use a specific java version. For example, sometimes I create a custom windows shortcut to open Eclipse using a specific version of the jdk.

    As of java 5, there's a tool named jconsole that might also help you determine which programs are running in which verions of jvms. Simply open a console, and type jconsole and you should get a nice GUI that shows all the programs running in the default jvm. I think you might even be able to inspect programs classpaths.

    Hope that helps, good luck!

    0 讨论(0)
提交回复
热议问题