Noclassdeffounderror Java


If you are a java developer, you definitely were experiencing java class not found exception with this error: noclassdeffounderror java . But what's behind this error?

We'll explain in next few lines:

Usually compiler tries to find a class within your classpath, but the class is not there. Therefore you're getting noclassdeffounderror.

Solutions:

If you are running a java command from command line:

1. Check included .jar files within your classpath

In windows environment type a command: "set"

Result should be something like:

C:\Windows\system32>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\m\AppData\Roaming
asl.log=Destination=file
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=BATMAN-PC
ComSpec=C:\Windows\system32\cmd.exe
configsetroot=C:\Windows\ConfigSetRoot
FP_NO_HOST_CHECK=NO
GIT_SSH=D:\Prog\TortoiseGit\bin\TortoiseGitPlink.exe
HOMEDRIVE=C:
HOMEPATH=\Users\m
LOCALAPPDATA=C:\Users\m\AppData\Local
LOGONSERVER=\\MicrosoftAccount
NUMBER_OF_PROCESSORS=6
OS=Windows_NT
Path=C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporati
on\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windo
ws\System32\WindowsPowerShell\v1.0\;C:\ProgramData\Lenovo\ReadyApps;d:\prog\Java
\bin\;d:\prog\Firefox\;D:\Prog\TortoiseSVN\bin;d:\prog\ant\bin\;d:\prog\svn\bin\
;D:\Prog\TortoiseGit\bin;C:\Program Files (x86)\Skype\Phone\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=AMD64 Family 16 Model 10 Stepping 0, AuthenticAMD
PROCESSOR_LEVEL=16
PROCESSOR_REVISION=0a00
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
READYAPPS=C:\ProgramData\Lenovo\ReadyApps
SESSIONNAME=Console
SVN_SSH=D:\Prog\TortoiseGit\bin\TortoiseGitPlink.exe
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\m\AppData\Local\Temp
TMP=C:\Users\m\AppData\Local\Temp
TVT=C:\Program Files (x86)\Lenovo
USERDOMAIN=BATMAN-PC
USERDOMAIN_ROAMINGPROFILE=BATMAN-PC
USERNAME=m
USERPROFILE=C:\Users\m
windir=C:\Windows


Then,
another command: set CLASSPATH=$CLASSPATH$"c:\{yourdirectorywithjarfiles}"

This should add visibility of your jar files within the classpath.

Optionally, you can specify a classpath this way:

java -jar mypackage.jar -cp c:\{yourdirectorywithjarfiles}


 

Add comment


Security code
Refresh


This website uses cookies to ensure you get the best experience on our website. Learn More.

Got It!