我正在使用此网站上的说明将JDK安装到Windows上
的过程中进行步骤6。当我尝试通过键入"c:"将当前驱动器设置为保存源文件Hello.java的驱动器时,没有任何反应(说明指示应该出现类似C:\xxx>的内容(。
我已经将 hello world 文件保存在 C: 目录中,如上一步(步骤 5(所示。
我正在尝试开始学习Java,任何帮助将不胜感激。
我建议您选择像 eclipse 或 Netbeans 这样的 IDE 来学习 Java,因为您正在学习您应该更多地关注语言基础知识而不是配置尝试使用 Eclipse IDE,它是开源的,非常适合 Java 开发,也是我的偏好。
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/marsr
试试这个链接,让你好世界变得容易
http://www.java-made-easy.com/java-hello-world.html
要编写"Hello World"程序,请按照以下步骤操作:
Start Eclipse.
Create a new Java Project:
File->New->Project.
Select "Java" in the category list.
Select "Java Project" in the project list. Click "Next".
Enter a project name into the Project name field, for example, "Hello World Project".
Click "Finish"--It will ask you if you want the Java perspective to open. (You do.)
Create a new Java class:
Click the "Create a Java Class" button in the toolbar. (This is the icon below "Run" and "Window" with a tooltip that says "New Java Class.")
Enter "HelloWorld" into the Name field.
Click the checkbox indicating that you would like Eclipse to create a "public static void main(String[] args)" method.
Click "Finish".
A Java editor for HelloWorld.java will open. In the main method enter the following line.
System.out.println("Hello World");
Save using ctrl-s. This automatically compiles HelloWorld.java.
Click the "Run" button in the toolbar (looks like a little man running).
You will be prompted to create a Launch configuration. Select "Java Application" and click "New".
Click "Run" to run the Hello World program. The console will open and display "Hello World".
您需要输入以下命令才能导航到 C:\驱动器(我不确定这是否区分大小写,只是为了安全起见,保持区分大小写(
cd C:
之后输入
dir
以确认您的文件是否存在。
然后使用 javac 编译
创建一个目录(例如 C:\myjava(,然后将 Hello.java 文件保存在 myjava 文件夹中。打开命令提示符并键入 cd c:\myjava。然后键入javac Hello.java来编译你的代码。
1(安装 JDK 后,请确保设置Java_Home路径。在这里找到它!
2(之后,在桌面上创建一个新文件并将其命名为"MyFirstJavaProgram.java">
3(右键单击并在记事本中打开新创建的文件。4(在其中插入以下代码。
public class MyFirstJavaProgram {
/* This is my first java program.
* This will print 'Hello World' as the output
*/
public static void main(String []args) {
System.out.println("Hello World"); // prints Hello World
}
}
5( 要编译该程序,请打开命令提示符并将其当前路径浏览到桌面。
6( 编写命令"javac MyFirstJavaProgram.java"
7( 监视程序写入命令的输出"java MyFirstJavaProgram"
输出将在控制台上。
您需要输入以下命令:
C:Users>cd
它将导航到 C: 驱动器,然后应用命令导航到保存源文件 C:\xxx 的文件夹
C: >cd xxx
然后你会得到..
C:xxx>