Java foundation-lesson1-environment variables

Source: Internet
Author: User

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

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.