How to run and compile java program?

自古美人都是妖i 提交于 2019-12-02 10:57:54

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/11265630/how-to-run-and-compile-java-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!