Agan Java--lesson1

Source: Internet
Author: User

Agan Java--lesson1to do any language development work, the first to configure its development environment, Java is no exception, start:
Test environment variables: Mainly involves two commands, Javac and Java
 
First, open your command line, enter "Cmd", will pop up the Windows operating system DOS interface, if this step does not pop up, it may be because the system file cmd.exe damaged, you from the other computer to copy a C:\WINDOWS\system32 below it can be;

Second, enter the command Java, you will see a directory-like east, enter the command Javac will prompt " ' Javac ' is not an internal or external command, nor is it a running programor batch file. " 1, because in the implementation of the fileC:\WINDOWS\system32\java.exe exist, so when you enter the Java command, the system is known, you can also understand for a while the WINDOWS operating system is supported by default Java language;
2, because the system does not install the JDK reason, so the javac command is not recognized, the JAVAC command is used to compile Java source code commands, corresponding to the JDK in the compiler;

Install JDK,JRE, configure environment variables (this section covers two environment variables Path,classpath)

First, install the JDK, my version is 1.5, the default installation path C:\Program files\java\jdk1.5.0_06; (This can change the default installation path according to your needs, but the recommended path name is preferably in English.) )
  Second, install the JRE, after installing the JDK, will pop up a window, let you choose the JRE installation path, the default installation pathC:\Program files\java\jre1.5.0_06;(if you need to change the installation path, the recommended path name is also best in English.) )
Note: These two steps in many integrated development environment now, only need to configure one on the line, the other will be the default configuration, or do not need to configure, some version of the IDE to help you finish.
 
after installation, configure the environment variables, right-click My Computer, tap "Advanced", click "Environment Variables", the interface is as follows

we will see above is the current user's environment variables, the following is the system environment variables, environment variables in the system appears in the syntax "xx=xxxx", if there are multiple paths "XX=XXXX;XXX; XX; X ", separated by semicolons, and so on. We find a system variable to explain the use of environment variables, if the user variable has an environment variable path=xx, the system also has an environment variable path=xxx, then the user's environment variable path=xx;xxx, if only the system variables or user variables exist path, Then the current user path is that one, no doubt, there is no two paths separated by semicolons.
Note: You can also use the command set to view all environment variables for the current user.
in the User variable column, click "New", Variable name path, variable value C:\Program files\java\jdk1.5.0_06\bin,

Click "New", variable name classpath, variable value ".; C:\Program Files\java\jre1.5.0_06\lib ",
Note: Notice that the path is a point "." Instead of a comma, this is important and you can understand it as a wildcard, in order to find the classpath.

after the path and classpath configuration are complete

Note: You can also add a new environment variable using the SET command, add a new command to the format "set Xx=xxxx", and remove the format "set xx=" for this environment variable.
 
Four, under the DOS system with the command to test again the environment variable is configured successfully, input javac, there will be a directory out, indicating that your environment variable configuration is successful,

write Test class, execute, observe running result: HelloWorld
First, create a new directory, named Lesson1, source file path F:\lesson\jbs\lesson1;
Second, create a source file, Helloworld.java, the code is as follows
Public class helloworld{

Public static void Main (string[] args) {System.out.println ("Agan java");      }
}
Note: If you create a file with a suffix that is Java, you can view it in the "My Computer--tools-Folder Options-View-hide extensions for known file types" to see if it is checked and removed. There are a number of ways to do this, for example, you can simply drag and drop files Helloworld.java to CMD or DOS to see if the file name extension is java.

Third, compile, explain the implementation
1, compile the source files, switch directories, commands


2, compile the source file Helloworld.java, command is Javac Helloworld.java, if your program is not a problem, will be in A class file called Helloworld.class is generated under the F:\lesson\jbs\lesson1 directory,

Note: This step is done by the compiler in the JDK.

3,   Execute class file, input command Java HelloWorld, output a string "Agan java",

Note: This step is done by the interpreter, the entire compile run process can be described, with the Javac command to the source file Helloworld.java using the compiler compiled into bytecode file Helloworld.class, Then use the Java command to interpret the execution bytecode file HelloWorld This class, rather than helloworld.class this file, emphasizing that we are doing the class is not. Class this file, through the interpreter to the byte-code file The HelloWorld class interprets the machine code instructions for the corresponding operating system and then executes the form and output of the operating system knowledge, so we can get a conclusion that Java is a language of the side-compilation side interpretation type. The
more complete explanation I will share with you in the following explanation.

        At this point, our first Java application was born ...

        2 hours to complete this log, absolutely original, and so on for a period of time to change a computer, as far as possible or video recording, these days first with text and picture form, the reason is very simple, the content is too limited, not enough plump, and self-feeling no video effect good. See you tomorrow, Friends of the Ming Dynasty.

Supplemental content:

1, the history of Java, for developers, see enough;

2, Java architecture, this needs to be written down first, the following will be expanded;

3, directory structure of JDK and JRE, etc.

Reference:
JavaOverview?JavaPlace of birth:SUN Microsystems Inc.–SUN:Stanford University Network?Javathe father:James Gosling
JavaA brief history of development?1991year appears?1995Annual Release?Latest Launchv8u31.
Java Technical Architecture

Java Application run mechanism
Advanced programming language types for computers:–Compiled type–Explanatory type?Javalanguage is the combination of two kinds;?Javasource program, byte code file, machine code instruction. JavaRun-time environment (JRE )
Javathree key features of the operating environment:–Load code: byclass Loadercompleted;–Checksum code: byBytecode verifiercompleted;–Execute code: byRuntime Interpretercompleted.
 JREthe installation configuration?JavaDevelopment Tools SetJDK----Java development Kits–Javacompiler–Javarun-time interpreter–JavaApplication Programming Interface–JavaDocumentation Tools–other tools and resources?Environment Variables–Path----the path to the executable instruction that specifies the operating system–
CLASSPATH----used to specifyJava The class file storage path.

If you want to learn Java development technology less detours, welcome to join my classroom, here are more Java technology enthusiasts to communicate with you, grow together.
about Us: Focus on Java software development, software training industry. 2006 engaged in Java Software development work, has been Wuhan soft Emperor technology information Limited liability company software Development engineer, Henan Jie Xun Senior research and development engineer, Shanghai Wei Xun Zhengzhou Qingyang vice president, Henan IBM University students training base marketing manager, Zhengzhou Soft Chong Technology Co., Ltd. General manager. CSDN Blog Address: http://blog.csdn.net/flywithcan,QQ:335816866, personal number flywithcan1983.
 

Agan Java--lesson1

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.