JAVA First Program "HelloWorld" __java

Source: Internet
Author: User

Junior last semester we opened a "Java program design" This course, using the teaching material is Bruce Eckel's "Java Programming idea" is the "thinking in Java fourth Edition" this book.
Lu Shaofei The first lesson taught us how to install the Java IDE and configure environment variables, and show us the first Java program "HelloWorld", so I decided to try today to write the first Java program to run.

Because I think it is not enough to listen to the class, so I learned on the school online "Java program, Tsinghua University computer Science and technology Professor Dengli", under the guidance of the course of my study.

First download the Java JDK on the official web, then configure the environment variables according to the video guide. There are two things to change: Java_home and Path, as shown in the figure



Java_home D:\Program files\java\jdk1.8.0_101\

Path%java_home%bin; added in front

It's worth mentioning that many tutorials or experiences on the Web, even our Java teachers, have told us that Java's environment variable configuration is cumbersome, but it's not that troublesome, and the video says that only this configuration is sufficient after JDK version 8.0. The value of path needs to first click the home key to reach the top.

The next step is to check whether the JDK's environment variables are configured.

"System Key +r" opens the command Input window, enters cmd to open the Cmd.exe and then checks


As shown in the figure, this is a good configuration of environment variables.

Next to write the first Java program, I set the file in the E disk, it must be said that the file settings are very important, if the beginning of the set in C, there will not be so many things, but after some toss, I have a further understanding of the CMD instructions.

"HelloWorld"

public class helloworld{public
   static void Main (string[] args) {
      System.out.println ("Hello World");
  }

As you can see, it's not difficult, and then save the file


Save As Helloworld.java

Then to generate the Helloword.class file, all of this is smooth, but, at the end of the execution, the various errors "cannot find or load the main class."

Baidu has a number of ways it is no use.

In fact, I think there is a way to use the Java command under the CMD "unable to find or load the main class" problem-click on the open link to look quite right, but it is no use ...







Finally I had to bow to the evil forces, in the C disk to create a Java folder, put the program in there, and learn from the blog Java environment variables detailed---Cannot find or load the main class-click on the contents of the open link, successfully run.


C:\Documents and SETTINGS\ADMINISTRATOR>CD C:\java


C:\java>javac Helloworld.java


C:\java>java HelloWorld
Hello World

Then I learned the Bishi 23333, and successfully ran the "HelloWorld" in the e-disk program.


Alas, the baby heart is very tired, finally has a relatively good beginning.

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.