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-freemarkerjob/target/classes/") });
Class c2 = mycl.loadClass("com.ctrip.market.sem.freemarkerjob.dynamicjava.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
String.Replaceall(Regex) Makes the Same Replacement Twice
How to Change UI Depending on Combo Box Selection
Get Width and Height of JPAnel Outside of the Class
Get Source Jars from Maven Repository
Getting Random Numbers in Java
Make Documentbuilder.Parse Ignore Dtd References
Java Thread Garbage Collected or Not
What's the Best Way to Distribute Java Applications
How to Add Directory to Classpath in an Application Run Profile in Intellij Idea
Build Eclipse Java Project from Command Line
Java String Remove All Non Numeric Characters But Keep the Decimal Separator
How to Check If a Single Character Appears in a String
Design Patterns: Factory VS Factory Method VS Abstract Factory