Java environment variable Configuration

Source: Internet
Author: User

What is the difference between a JDK and a JRE when configuring a Java environment variable to determine whether to install JDK or JRE primarily through the user's purpose?

Now let's take a look:

1,JRE is the Java Runtime environment. Java runtime Environment, mainly Java users, or operators to download the configuration.

2,JDK is Java Developor tools. Java development tools, mainly Java developers, or programmers to download the configuration. Now that Sun has been acquired by Oracle, you can download the JDK or JRE on Oracle's website, which depends on the two points we mentioned above

When installing the JDK, a standalone JRE runtime environment is included, and if you install a separate JRE runtime environment in the JDK, the Windows JDK installer automatically puts a copy of Java (. exe) to C:\Windows\system32, This is why there is no need to configure the direct execution of Java directives. However, if you do not install a separate JRE runtime environment when you install the JDK, but instead use the Java Runtime Environment under the JDK, you will need to set the path to the JavaScript Development compilation tool in the path path.

The command to start the JVM is Java.exe, and the purpose of executing the Java command is to start the JVM virtual machine. Indicates which class file the virtual machine is required to execute

At compile time (javac.exe), you need to specify the path to the Javac.exe, or configure this file path in the path path

Java programs do not use the following methods when running class files:

Java F:\run\Hello

The reason is that the name of our. Class bytecode file is Hello, and the Java runtime does not have a-classpath parameter that represents the lookup from the current path, so there is no file named F:\Hello under the current path. So how should we run it?

The answer is: Java-classpath F:\run Hello (note that there is a space before Hello), where Java will begin to look up the Hello bytecode file in the F:\run directory and execute it in the JVM virtual machine.

So what if we want to be under multiple paths? You can concatenate the arguments after the-classpath in a comma-compatible way.

Java-classpath F:\run;d:\workspace Hello, this means class loading in two directories, so what if we still want to load the current directory? Do you want to write the current path address? Here's a place to be aware that we can use a point to represent the current path.

Java-classpath.; F:\run;d:\workspace Hello, this means class loading in three directories

The CLASSPATH environment variable is read when the JVM is started, that is, when Java is executed, if the classpath is not specified with-CP or-classpath. Similarly, the setting in command prompt mode fails after the mode is closed. If you want to apply a classpath to the command prompt mode every time you turn it on, you can also set it in a system variable or user variable. If execution uses-CP or-classpath to specify CLASSPATH, the specified-CP or-classpath is the primary.

In fact, when using Javac to compile a program, if you want to use the other Class link library, you must also specify Classpath, tell Javac compiler where to find the. class file

Java environment variable Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.