Introduction to Android development (1) installation and configuration of Java Jdk, androidjdk
1. First download the latest JDK from www.oracle.com
2. continue to the next step until the installation is complete.
3. Enter the java-version command in CMD. If the correct version number is displayed, the installation is successful.
4. Set the PATH environment variable
After successful installation, we can go to the java jdk installation directory C: \ Program Files \ Java \ jdk1.7.0 _ 79 \ bin in CMD to execute various JAVA commands, for example, JAVAC (compile command)
Wait a moment. Go to the bin directory of the installation directory of java jdk, and run CD... every time ............ Fortunately, Windows has come up with this. As long as we set the environment variable PATH, everything will be done. The same is true for other CMD commands.
Practice: Right-click "computer"-> properties-> advanced system settings-> environment variables-> system variables-> PATH, and add C: \ Program Files \ Java \ jdk1.7.0 _ 79 \ bin
Usage: You can use JAVA to execute commands in any directory of CMD. Enter JAVAC and try again.
5. Set the ClassPath environment variable
Write a Java program to test JDK installation, create the file HelloWord. java, and enter the code in the file
Public class HelloWord
{
Public static void main (String [] args)
{
System. out. println ("HelloWord ");
}
}
In the directory of the test program in CMD, enter javac HelloWord. java for compilation. After compilation is successful, one more HelloWord. class will be displayed.
Enter java HelloWord in CMD to run the program successfully. If the program fails to run in other CMD directories, the Class directory is incorrect,
Solution: Right-click computer> Properties> advanced system Settings> environment variables> system variables> ClassPath ), with the directory of the test program added, you can use java to run the program in any directory of CMD.
6. in JAVA, the class name must be the same as the file name