“Could not find the main class”

倾然丶 夕夏残阳落幕 提交于 2019-12-01 17:56:13

Right - the problem is that you've got HelloWorldDesktop.class in the current directory, whereas it should be in com/badlogic/gdx/helloworld

You can fix this with the javac command - just use -d . to tell it to treat "." as the package root directory for output.

Normally you would want to also organize your source code by package, but for this "hello world" test it may not be worth it.

Ok, first of all you need to compile and then run the app using two different tools

Step 1: javac.exe which compiles the .java files into .class files. Example: javac.exe ProgramFolder\*.java (where ProgramFolder = File System Directory)

then

Step 2: java.exe and give as parameter the app you want to run including the path, but instead of using "\" for folders use "." and the name of your class Example: ProgramFolder.ClassProgram

That will work. if you try to run Java.exe ProgramFolder\Program.class or just ProgramFolder\Program or go into the folder where the class files are and only do Java.exe Program.class it will always give you the cannot find Main class error.

Have a look at the first 2 lines of this picture http://3.bp.blogspot.com/-FO4Hmg9LrI0/Td7FoSIi_XI/AAAAAAAAF6g/FVAiP0h8CSc/s1600/fiborial_java.PNG

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