0

I tried to compile and run Java 10 file with TextPad, it works nicely until I decide to put the file in a folder and use Package(namespace). It seems to be unable to load classes, I get this error:

Error: Could not find or load main class com.MyProject.HelloWorld
Caused by: java.lang.ClassNotFoundException: com.MyProject.HelloWorld

Is there anything I can do about this? I dont seem to find how it is possible to define the class path in TextPad, so I am stuck.

Lord Yggdrasill
  • 3,197
  • 4
  • 26
  • 42

2 Answers2

0

You need to compile it like this:

>javac ./com/MyProject/HelloWorld
Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108
0

After the compiling... From the console, try to specify the java HOME, then the path, then the module and the main class: For example:

"C:\Program Files\Java\jdk-10\bin\java.exe" -p C:\Users\User\MyFolder -m com.mymodule/com.MyProject.HelloWorld

zlakad
  • 1,314
  • 1
  • 9
  • 16
  • I see. I already set java home to be "C:\Program Files\Java\jdk-10.0.2" from System Environment Variable Settings. What do I need to do from here? To add class path? I am using TextPad, I wonder if anything can be done directly in this editor. – Lord Yggdrasill Oct 02 '18 at 19:18
  • I'm sorry, but I didn't use TextPad. Also you have to add `\bin` to your java home env variables. Then you can use `java -p -m ` – zlakad Oct 02 '18 at 19:52