Lab one: Familiarity with the Java development environment
One: Experimental content:
- Use JDK to compile and run simple Java programs;
- 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