Lab one: Familiarity with the Java development environment

Source: Internet
Author: User

Lab one: Familiarity with the Java development environment

One: Experimental content:

    1. Use JDK to compile and run simple Java programs;
    2. Use Eclipse to edit, compile, run, and debug Java programs.

Experimental steps:

(i), command-line Java program development

1. Use the Xface command line operation:

Enter code:

To set up the experiment directory, use the LS command or the dir command to view the established directory situation:

InputCD 20135204Enter the experiment directory. Re-establishExp1. input pwd command to view the current working path.

Edit the Hello.java and enter the code:

Compile:

Open Eclipse and create a new project:

Create a new class:

Enter the code and compile the result that appears below:

After setting the power off, stop at line fourth:

Point Step over:

Third, practice

5. Realize the function of all prime numbers between 1-n integers and check.

Code:

Package Hzy;

import Java.util.Scanner;

Public class Prime

{

Public Static void Main (string[] args) {

Scanner sc = new Scanner (System. in);

System. out. println ("Input N:");

int n = sc.nextint ();

for (int i=2;i<n;i++)

{

int count=0;

for (int j=2;j<=n;j++)

{

if (i%j==0)

{

count++;

}

if (J==i & Count==1)

{

System. out. Print (i+ "");

}

if (count>1)

{

break;

}

}

}

}

}

Debug with Eclipse:

With the command line:

Iv. problems encountered in the test and their solutions:

1. At first, you are unfamiliar with the insertion breakpoint, so there is a problem with stepping through the debugging. After reading the experiment guide carefully, I found that the button I ordered was wrong. Only then did it succeed.

2. In the final experiment, it was found that there was a difference between the command line and the use of eclipse in the package.

3. Because my editplus can't be used, I can only use Notepad. The command line cannot be run at the beginning, and the discovery is automatically hidden. Java.txt behind the TXT, so the full display after the deletion of TXT, you can run.

Five, the experiment Harvest:

This incident cost a lot of events and energy, first installed a new software eclipse, and the use of Notepad instead of EditPlus, solve a lot of problems.

There is the first time to use the lab building and blog, the feeling is still very systematic but also very complex. But after so many steps, I find that the mastery of the computer has improved.

In particular, exercise their ability to solve problems. It's also useful for me to lift more new things.

Lab one: Familiarity with the Java development environment

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.