如何运行和编译java程序? [英] How to run and compile java program?
本文介绍了如何运行和编译java程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编译一个简单的程序
class Test {
public static void main(String [] args) {
System.out.println(Hello);
}
}
我在命令提示符中输入java Test.java
但不起作用
无法找到或加载主类Test.java
我没有使用任何IDE
我应该把程序文件放在我的电脑上
谢谢
解决方案您不能直接运行java源文件。您需要先使用
javac
编译它:javac Test.java
然后你得到一个.class文件,你可以运行:
java Test
I am compiling a simple program
class Test { public static void main(String[] args) { System.out.println("Hello"); } }
I typed in command prompt java Test.java But it did not work
Could not find or load main class Test.java
Im not using any IDE
Where should i place the program file on my computer
Thank you
解决方案You cannot directly run a java source file. You need to compile it first using
javac
:javac Test.java
Then you get a .class file that you can run:
java Test
这篇关于如何运行和编译java程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文