Java Learning (ii) Development environment configuration

Source: Internet
Author: User

In our last study, we knew that while installing a Java integrated development environment, you had to install a JDK, either SE, or EE, or me, based on the needs of your own development project type. But SE is the foundation of EE and me. So let's install the SE JDK first.

1. Download and install the SE JDK

1. Baidu "JDK Download", choose Baidu Software Center, according to the computer version select Download can

2. Install directly by default next installation is good, or refer to some JDK installation tutorial, note to modify the installation path

PS: When installing, the JDK is installed first, then the JRE will be installed, so you will see that you choose two times the installation path, specifically why I do not specifically understand, refer to the blog:

The http://www.cnblogs.com/wencansz/archive/2012/11/08/2760311.html above has a more detailed explanation.

2. Configure three environment variables--System variables

When it comes to how to configure, let's take a look at what these three variables mean, why configure them?

All Java programs are first compiled into a class file of. class, which can be executed on a virtual machine. Since the code compiled by the Java program is not code that can be run directly by the hardware system, it is an "intermediate code"-bytecode. Then there are different Java virtual machines (JVMS) installed on different hardware platforms , which is why we should choose our own hardware system when we download the JDK.

The JVM will then "translate" the bytecode into code that the corresponding hardware platform can execute. So for Java programmers, there is no need to consider what the hardware platform is. So Java can be cross-platform. Because it has a virtual machine (JVM), the Java program is not running directly on the computer, it is on the virtual machine, each system platform has its own virtual machine (JVM), so the Java language can cross the platform. This means that class does not directly correspond to the machine's operating system, but rather interacts with the operating system indirectly by the virtual machine, which interprets the program to the local system for execution.

Only the JVM is unable to complete class execution because the JVM needs to invoke the class library lib that is required to interpret the class, and the JRE contains the Lib class library. The JVM masks information that is relevant to the operating system platform, allowing Java programs to run without modification on multiple platforms by generating only the target code (bytecode) that runs on the Java virtual machine.

In the picture below, let's compare the differences between the compilation run between Java and C + +:

2.1CLASSPATH

What is Classpath? What is the role of it?

It is an environment variable of the Javac compiler.

its role is related to import, the package keyword. when you write down Improt java.util.*, when the compiler faces the import keyword, you know you want to introduce java.util the class in the package, but how does the compiler know where you put the package? So you first have to tell the compiler where the package is located, and how do you tell it? is to set the classpath.

If java.util this package in the C:\jdk\ directory, you have to set c:\jdk\ this path to Classpath! When the compiler faces the import java.util.* this statement, it first looks for the directory specified by Classpath and checks to see if the subdirectory java\util exists, and then finds the compiled file (. class file) that matches the name. If you do not find it will be an error!

Classpath is a bit like the settings of the include path in the C\c++ compiler oh, isn't it? When the C\c++ compiler encounters a statement such as include <iostream>, how does it work? Oh, the truth is almost the same! Search the Include path to view the file!

When you develop a package yourself, and then want to use the class in the package, naturally, you also have to set the directory where the package resides in Classpath!

2.2PATH

Path environment variable. The function is to specify the command search path, execute the command below the command line, such as Javac compiling the Java program, it will look in the path specified by the paths variable to see if the corresponding command program can be found. We need to add the bin directory in the JDK installation directory to the existing path variable, and the bin directory contains the frequently used executables such as Javac/java/javadoc wait, and after setting the path variable, you can execute the Javac/java tool in any directory.

2.3java_home

Java_home environment variables. It points to the JDK's installation directory, and software such as Eclipse/netbeans/tomcat finds and uses the installed JDK by searching for java_home variables.

2.4 How to configure

On the Windows desktop, right-click "My Computer", "Properties", "Advanced", "Environment variables", in "system variables" we can see the values of the system's various environment variables. Double-click a variable name to modify the value of the variable, using ";" between the variable values. Separated. We can also "create new" variables that were not previously available. There are 3 environment variables associated with the JDK, "java_home", "path", "Classpath". The "path" variable already exists in my system, can add the new value directly (other variable values do not move, prevent other programs to run the exception), the other two variables need to be new.

"Java_home", set the JDK installation path, such as "e:\java\jdk1.5", hereinafter referred to as "%java_home%".

"Path", set the path of each program in the JDK, "%java_home%\bin;%java_home%\jre\bin;"

"Classpath", set the path of each class in Java, ".; %java_home%\lib;%java_home%\lib\tools.jar ". The previous "." No less, it represents the working path we have built for our Java class, and the other is the standard class library path that comes with the JDK.

After setting the environment variable, press OK to exit. Press "Win" + "R" key into the "Run" window, run "cmd" into the DOS window, enter "Javac" after entering, if there is help information showing Java, the environment variable setting is successful.

2.5 Specific List

Classpath= ".; %java_home%\lib;%java_home%\lib\tools.jar "=" C:\Program files\java\jdk1.5.0 "="%java_home%\bin; %java_home%\jre\bin "

3. Download and install MyEclipse

Last download install an IDE you want to use, such as eclipse,myeclipse, etc.

Java Learning (ii) Development environment 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.