无法在Eclipse创建的命令行中运行Java文件 [英] cannot run java file in command line that created by eclipse
问题描述
如果我在命令行中通过touch命令创建Java文件,请使用nano对其进行编辑,通过javac进行编译,然后运行它,一切正常.
If I create Java file by touch command in command line, edit it using nano, compile it by javac, and then run it, all works well.
但是,如果我使用eclipse构建项目,并在eclipse中创建文件.我可以使用javac对其进行编译,但无法在命令行中运行它.
But if I use eclipse to build the project, and create file in eclipse. I can compile it using javac, but cannot run it in the command line.
它显示
错误:找不到或加载主类
Error: Could not find or load main class
为什么会这样?有什么问题吗?
why this happen? is anything wrong?
推荐答案
听起来与尝试运行类的正确路径有关.您使用包裹了吗?您是从bin | target | build目录运行它的吗?请提供您尝试执行的命令和路径
sounds like all about right path in which you trying to run your class. did you use packages? did you run it from bin|target|build dir? please provide commands and paths from which you trying to execute it
这篇关于无法在Eclipse创建的命令行中运行Java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!