Search code examples
javaeclipsejavaw

Eclipse 4.7.3a and Java 10 Error: Could not find or load main class


I just installed a new Eclipse on my laptop with Windows 10 pro. Here is the Eclipse Version:

Eclipse Java EE IDE for Web Developers.  
Version: Oxygen.3a Release (4.7.3a) Build id: 20180405-1200

My java version:

java version "10.0.1" 2018-04-17  
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)  
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

My test code:

package questions;  

public class TestMain {

public static void main(String[] args) {
    System.out.println("test");
    }
}

Command line execution under the test\bin directory created by Eclipse

java questions.TestMain

works fine.

But I can't get it work with in the Eclipse. Using "run as a java application" with

C:\Program Files\Java\jre-10.0.1\javaw.exe

always produces the following error:

Error: Could not find or load main class questions.TestMain  
Caused by: java.lang.ClassNotFoundException: questions.TestMain

Any help is appreciated.


Solution

  • It turned out the Eclipse workspace is under the directory with non ascii characters. Even though within the workspace everything (creating the project, compiling, etc) seemed fine, javaw.exe couldn't reach the bin directory.