one, Run when environment variables are not configured Java Programs
D:\java-wangying\javase\java\jdk1.7.0_79\bin>javac D:\Java-wangying\JavaSE\code Helloworld.java
Compiling Java Programs When environment variables are not configured
Hello world!
D:\java-wangying\javase\java\jdk1.7.0_79\bin>java-classpath D:\Java-wangying\JavaSE\code HelloWorld
running Java programs
Hello world!
D:\java-wangying\javase\java\jdk1.7.0_79\bin>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/88/04/wKioL1fn3c-jAlb_AAFKAQnLyy4273.jpg-wh_500x0-wm_3 -wmp_4-s_2874724459.jpg "style=" float:none; "title=" 1.jpg "alt=" wkiol1fn3c-jalb_aafkaqnlyy4273.jpg-wh_50 "/>
second, Configure Environment variables
Right button "my computer"--"properties"--"advanced settings"--"environment variables"
Configure three environment variables: Java-home;CLASSPATH;Path(no Environment variable, some edit directly)
JAVA-HOME:JDK Installation Path
CLASSPATH:Java Program Path
Path: file path
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/88/08/wKiom1fn3dDS3XmnAAH61DRlyeA422.jpg-wh_500x0-wm_3 -wmp_4-s_3514987120.jpg "title=" 2.jpg "style=" float:none; alt= "wkiom1fn3dds3xmnaah61drlyea422.jpg-wh_50"/>
Iii. Preparation of Java Program Helloworld.java
public class HelloWorld {
public static Voidmain (string[] Arg) {
System.out.println ("helloworld!");
}
}
the file name and class name are the same
Iv. Compile and run
public class HelloWorld {
publicstatic void main (string[] Args) {
System.out.println ("helloworld!");
}
}
Javac-d bin Src/helloworld.java
/**
-d means the specified storage path, that is, the compiled file into the * * folder, such as no- D will be directly compiled into the * * folder
*,
Java-cp bin HelloWorld// run,-cp Specifies the path where the program Runs.
This article is from the "12086808" blog, please be sure to keep this source http://12096808.blog.51cto.com/12086808/1856436
Java foundation-lesson1-environment variables