ajsie
ajsie

Reputation: 79806

is the command "java" the JVM?

whenever they say run a .class file in JVM. do they mean with the command "java" in the terminal.

or can you click on it to open it?

Upvotes: 7

Views: 987

Answers (6)

adrian
adrian

Reputation: 1457

a .CLASS file is Java bytecode. It is not strictly meant to be Java (some other languages have the same bytecode structure). JVM may refer to the command java or javaw. The only diffrence is that java is meant to run console applets while javaw is for window interfaces. For example, Minecraft (a major Java app) contains a standalone launcher (a native Windows application). It uses javaw because it has it's own special window container, etc.

Upvotes: 0

Upgradingdave
Upgradingdave

Reputation: 13076

A java file is compiled into a class file, which is a bunch of java bytecode. The JVM is the thing that can execute java bytecode.

java is a command line tool that is part of a java runtime environment (JRE) that knows how to start a java virtual machine, load and execute your class file.

Upvotes: 4

harschware
harschware

Reputation: 13424

As mentioned in other posts the java command, or executable can be used to create a running JVM. But there are other ways you find a JVM, which are usually finding java for you via your JAVA_HOME such as running tomcat (a web server for java, sometimes called a "container"), Java WebStart which synchs a java distro to your local system and launches it in a JVM and Java Applets (old school attempt at to broaden the use of java on the web where Java is being run directly within the browser). Essentially they all create a JVM via calling java.exe or one of its siblings in the JRE (eg. javaw.exe).

Upvotes: 0

Uri
Uri

Reputation: 89839

The Java JVM can be packaged in different ways and started with various executables.

The standard way that most developers start the JVM is indeed with the java.exe. However, this is a command line program, so you need to provide it with extra detail: the name of the class that contains main, and often the classpath which is used to find the classes to load.

In most operating systems, clicking the Java icon wouldn't do anything since it will merely run the executable without any parameters, and the executable will just exit without running anything. If you want to double-click in Windows, create a shortcut and add the relevant command line parameters to the command after the java.exe part.

Upvotes: 2

pstanton
pstanton

Reputation: 36689

  1. yes, you use the java command to launch an instance of the JVM or java virtual machine.

  2. depending on your operating system you could hook something up to double click a class file, what is your os?

Upvotes: 1

mdm
mdm

Reputation: 12630

Yes, if you have the JRE installed, java should be the JVM.

Upvotes: 5

Related Questions