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

Can I run multiple JVMs? If so, how can I find a specific class that is loading, on which JVM?

+7
java
source share
7 answers

It's not entirely clear what you mean, but:

  • You can install more than one virtual machine on one computer (version / brand, etc.).
  • You can run more than one java process, whether from the same version of the JVM or different

Unless you are using a debugging agent or something similar, I donโ€™t know how to request the JVM process to load a specific class. It seems a little weird requirement - why are you doing this?

+12
source share

Yes, you can run multiple JVMs on the same machine.

Sun packs jvm startup tools in several ways. Usually you either have the java development kit (jdk), or the standard java (jse) version installed by default. These packages include the java program, which is called to start jvm. In addition, jdk also contains additional commands (e.g. javac ) for developers.

You can have multiple jdk and / jse available on the same machine. On windows, jdk and jse packages are usually installed under Program Files/java (this is from memory, because at the moment I do not have a PC)

On a Mac, see /System/Library/Frameworks/JavaVM.framework/Versions.

On Linux, I would use the which java command to determine where the default java command is installed (usually / usr / bin). Then do ls -al | grep java ls -al | grep java (for example, inside / usr / bin) and note where the point of the symbolic links is to determine where other versions can be installed.

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

Each java program is launched using jvm by default. Open a command window or terminal and try java -version determine which version is the current default value.

Instead of using the standard java version, programs can also be launched to use a specific version of java. For example, sometimes I create my own shortcut for Windows to open Eclipse using a specific version of jdk.

Like in java 5, there is a tool called jconsole , which can also help you determine which programs are running, in which versions of jvms. Just open the console and enter jconsole and you will get a good graphical interface that displays all the programs running in jvm by default. I think you can even check out classpaths programs.

Hope this helps, good luck!

+6
source share

You can run as many JVMs as you can fit on your disk and in memory :)

Whenever you start a Java application, you start the JVM first and then tell which application to run. The answer to โ€œwhat kind of JVMโ€ is simple: the JVM you downloaded with the app!

Itโ€™s possible to make some esoteric messing around with class loaders, which will be the exception to what I just said. But this is true in the general case and in most applications.

+4
source share

Can I run multiple JVMs?

Yes - just run the java process

If so, how can I find the specific class to which the JVM is loading?

The jps program, distributed with the JAVA SDK, will display all the java processes (JVMs) on your computer, the main class that each JVM and classpath execute. You will need to see which banks or classes are in each class path to find out if the class is loaded or not.

try to run

 jps -mlvV 

and look what you get

+3
source share

Yes, you can install more than one jvm on your PC, because the OS loads an instance of jvm (not the whole jvm) into RAM. We can call different jvm, such as JDK 1.4 or JDK 1.6, setting our path.

+1
source share

A lot of JRE (Java Runtime Enviroment) is very possible. I'm doing it. The fact is that the JVM does not always work on your system. It is like any other software. When you run the jar file, it starts.

By default, JRE is set in environment variables as JAVA_HOME (right-click my computer -> properties -> tab with tab -> environment variables)

To run the jar file, you simply run this command:

C: \ Program Files \ Java \ j2re1.4.2_04 \ Bin \ javaw.exe "-jar Myfile.jar

You can use any other jre javaw to run the jar file.

Please note that j2re1.4.2_04 may not be your version of jre.

Edit:

All classes in the jar file run on the same JVM. As you can guess. See your JAVA_HOME, it is by default.

0
source share

You can run as many JVMs as you want on the same machine. You just need to open several CommandPrompt windows and run what you want using a java or javaw . The class in which the JVM runs is the THAT class, which contains the main() method. The Main () method is the first thing that starts when a Java application starts. Of course, main () is in some of your classes. It's all.

0
source share

All Articles