How do I run a single Java file having main() in Eclipse, without creating an entire Java project?

后端 未结 4 1677
夕颜
夕颜 2021-02-13 14:43

Here\'s what I\'ve got:

  1. I have a TestFile.java with the same class name.
  2. This class has a valid main() method.
  3. The file
4条回答
  •  执笔经年
    2021-02-13 15:07

    You can't compile & run just one file in Eclipse without the file being in a java project.

    It is a very quick and easy process to create a Java Project in eclipse.

    File -> New -> Java Project
    

    You can use the default package (though it is not recommended) and put your single file in it and run it.

提交回复
热议问题