Java language development environment

Source: Internet
Author: User
Tags java se

"How to build a Java development environment""Introduction"The full name of the JDK isJava Development Kit, the Java Standard Edition Development Kit. Sun offers a suite of development packages for developing Java applications that provide the tools and resources needed to compile and run Java programs. This includes the Java compiler, the Java Runtime Environment, and commonly used Java class libraries. Java Runtime Environment (Java Runtime Environment) JRE. is a required condition for running Java programs. The JRM contains the JVM. The JVM is the core virtual machine that runs Java programs. JRM containsJVM, class loader, bytecode Checker, and a large number of base class libraries. If you are just running a Java program, you can install only the JRE without installing the JDK. Oracle only provides downloads for the JRE. Oracle divides Java into three parts: Javase, Java EE, and Javame. Two development packages for the JDK and Java EE SDK (software Development Kit) are provided for Java SE and Java EE respectively. There is a Java EE SDK version that already contains the latest version of the JDK, and the installation of the SDK includes the JDK."Download and install JDK"① Login: http://www.oracle.com/technetwork/java/javase/downloads/index.htmljdk-DOWNLOAD② Select the Windows installation package ③ Download the JDK-10.0.1 installation package. (Accept License Agreement) ④ download File Jdk-10.0.1_windows-x64_bin.exe successful, double-click to run the installation. ⑤ installs the core of Devepment TOOLS:JDK, including the necessary command tools for compiling Java programs. The inclusion of the JRE (which will be installed in subdirectories of the JDK installation directory) is also the reason why you do not need to install a public JRE. Source code: Installing this option will install all of Java's core class library sources. Choosing not to install in a path with spaces may cause some unknown problems. After the ⑥ installation is complete, you can see the following path under the JDK installation path. (explained by Jdk1.7.0_75)Bin: A variety of tool commands for the JDK, commonly used Javac, Java and other commands are blocked under this path. DB: The path is installedpath to Java db. Include: some platform-specificheader file. JRE: Installed under this path is required to run a Java programJRE Environment. Lib: This path is stored in the actual execution of the JDK tool command, if you use WinRAR open the Tools.jar file under the Lib path, you will see Tools.jar\sun\tools\javac main.class Used to compile the Java program.the Javac.exe command is written using Java. This class is the Main.class class in Sun\tools\javac in the Tools.jar file under the Lib path .Most of the commands in the bin are packaged with the tool class in the Tools.jar file. Src.zip: The compressed file contains the source code for all Java core class libraries. Explanatory documents such as Readme and license."Set PATH environment variable"2 steps required to compile and run a Java program: ① compiles the source file into bytecode. The Java command ② explains the execution of platform-independent bytecode programs. "Javac Command""Test if you can use these two commands"
Although the JDK was installed on the computer (with both commands), the computer did not know where to look for the two commands. The Windows operating system looks for commands based on the PATH environment variable. The PATH environment variable stores a series of paths. The system can be searched sequentially according to its specified path. To find, you can compile and run the Java program by simply adding the path of the Java and Javac two commands to the PATH environment variable."Win7 Setting environment variables"Computer right--Properties, advanced system settings, advanced click Environment variables are divided into user variables and system variables without the PATH environment variable, then add, or modify. (Windows variable case is not sensitive) the value after appending the variable is the path of the installation: D:\Program files\java\jdk1.7.0_75\bin user variables and system variables are set, the priority is to use theUser Variables. "Continue testing if you can use these two commands" java command test:The Javac command test can be used."First Java program"Edit the source code Editor: Notepad,editplus and other programs. cannot be edited with WordPad or Word, there are hidden formatting characters in the tool that cause the program to fail to compile and run. Java is strictly case-sensitive. "Source program" Helloworld.java
public class HelloWorld
{
Java Program Entry method, the program will start from here to execute
public static void Main (string[] args)
{
Print a statement to the console
System.out.println ("Hello world!");
}
}
Compile the Java program with Javac. "Syntax format": javac-d destdir Srcfile-D destdir: Specifies a valid path on the local disk.
Srcfile: Where the source files are located. Note: The 2 paths here can be absolute or relative. Javac generated target file name: The class name of the class as defined by the source file, with a. class as the suffix name, and the-d parameter is specified as the current position by default when it is not written. "Compile results" "in EditPlus the Configuration tool integrates Javac into" tools->configure User Tools->group name written ( compile run Java) written in Add tools Menu text: Compiling Java programs Command:javac argument:-d. $ (FileName) initial:$ (Filedir) "Compiling Java programs" has been added to tools  "Run Results"
Command-line Syntax: Java Java class name
The class name is consistent with the source file name and the class file prefix. Here is the "HelloWorld" in the EditPlus Configuration tool to integrate Java into the tools->configure User Tools->group name selection ( Compiling run Java ) written in Add tools Menu text: Running Java programs Command:java argument:$ (Filenamenoext) initial:$ (Filedir)Write Helloworld.java (the file name needs to be the same as the class name, public, and have only one public): "Ctrl+1" "ctrl+2""Classpath of Java" More than 1.5 JDK versions are completely free from setting this environment variable. The above example can be compiled and run even if it is not set. Classpath the role of the environment variable: "Java Java class name" When running a Java program. The JRE searches for Java classes in the path specified by the CLASSPATH environment variable. CLASSPATH environment variable:%java_home%\lib\dt.jar;%java_home%\lib\tools.jar (%java_home% represents the installation directory for JDK) later JRE willautomatically searches for class files under the current path, and when using Java and Javac, the system can automatically load Java classes in Dt.jar and Tools.jar filesIf you want to run the Java programTo temporarily specify the path to the JRE search class, you can use the-classpath option to run the Java command in the following format. java -classpath dir1;dir2;dir3 ...; Dirn Java class java -classpath %classpath%;.; Dir1;dir2;dir3 ... ; Dirn Java class %classpath%; to refer to the value of the environment variable CLASSPATH and add a point in-classpath to search for Java classes under the current path.
"Basic rules that Java programs must meet"A Java program is a purely object-oriented programming language that must exist in the form of a class. Class is the smallest program unit in Java. All programs must be placed in the class."The simplest Java program"
Class Test
{
}
This is one of the simplest Java program Java interpreter rules: If a class can be interpreted directly by the interpreter, the class must contain the main method, and the main method must be decorated with public static void, and the main method's formal parameter must be a string array type ( String[] args is the form of a string array). The Main method is the entry for the program."Java source file naming rules"①, suffix. Java②, typically, the Java program source file name can be arbitrary. However, there is one case exception. The Java Program source code defines a public class that must match the class name of the public class. That is, only one public class can be defined in a Java source file. "Program interpretation" public static void Main (string[] args) above the program entry is fixed. Where public and static can be interchanged System.out.print (content that needs to be output); SYSTEM.OUT.PRINTLN (content that needs to be output); To console output, the former will not wrap after the output ends, and the latter will wrap after the output."garbage collection mechanism"The Java language does not require programmers to directly control memory collection, and the memory allocation and recycling of Java programs is automatically run by the JRE in the background. Java's heap memory is a run-time data area that holds instances of classes (objects) The JRE provides a background thread for detection and control, and is typically garbage collected automatically when the CPU is idle or out of memory, and the programmer is not expected. This mechanism is a garbage collection mechanism (garbage COLLECTION,GC). The advantages of this mechanism: 1. Improve programming efficiency. 2. Protection of the integrity of the program, garbage collection is an important part of the Java language security policy. Disadvantages: Overhead affects program performance. 1. Tracking useful objects to confirm useless objects and freeing useless objects takes processor time. 2. Garbage collection algorithm is not complete, with the algorithm improvement, software and hardware efficiency improvement, the problem can be solved. features: Reclaims the memory space of useless objects in the JVM heap. (Powerless against physical resources)"About IDE Tools"For beginners, do not use any IDE tools to learn Java programming, I am learning the Java language, not any tool."工欲善其事, its prerequisite"----Study Notes

Java language development environment

Related Article

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.