Noclassdeffounderror: Wrong Name

NoClassDefFoundError: wrong name

Exception in thread "main" java.lang.NoClassDefFoundError: ClientREST

So, you ran it as java ClientREST. It's expecting a ClientREST.class without any package.


(wrong name: clientrest/ClientREST)

Hey, the class is trying to tell you that it has a package clientrest;. You need to run it from the package root on. Go one folder up so that you're in the folder which in turn contains the clientrest folder representing the package and then execute java clientrest.ClientREST.

You should not go inside the clientrest package folder and execute java ClientREST.

Java.lang.NoClassDefFoundError wrong name: how to solve this?

You should run the command (in Windows)

java my\package\HelloWorld

from the directory build/classes/main and not from build/classes/main/my/package. This is because HelloWorld class declares that it resides in the package my.package with package my.package;.

Got NoClassDefFoundError: wrong name with Windows path

I think you have to change your URL to point to classpath and load class by package name, like this

URLClassLoader mycl = new URLClassLoader(new URL[] { 
new URL("file:///D:/Users/XXX/Desktop/sem-material-job/sem-material-‌​job/sem-material-fre‌​emarkerjob/target/cl‌​asses/") });

Class c2 = mycl.loadClass("com.ctrip.market.sem.freemarkerjob.dynamicja‌​va.TEST123");

java.lang.NoClassDefFoundError ... (wrong name: ....)

I've found the problem. It was the IDE (Dr. Java).

I am not sure what happend but today when I opened it, it crashed. Then, I opened it again and all the settings were set to default. I had to set all the preferences again and everything worked just fine.



Related Topics



Leave a reply



Submit