Error message - Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main

From my Vista command-line prompt, I get the following error message when I enter the following command

C:\myJavaClasses>javac Hello.java
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: com.sun.tools.javac.Main.  Program will exit.
C:\myJavaClasses>

C:\myJavaClasses>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\jdk1.6.0_18\bin;

C:\myJavaClasses>
/**
 * The Hello class implements an application that
 * simply prints "Hello World!" to standard output.
 */
public class Hello 
{
    public static void main(String[] args) 
	{
        	System.out.println("Hello World!"); // Display the string.
    	}
}

Open in new window

areyouready344Asked:
Who is Participating?
 
mahomeConnect With a Mentor Commented:
Here's a description how to set JAVA_HOME: http://www.advancedwebstats.com/user-guide/html/en/ch05.html#install-java-win

you have to set it to: c:\jdk1.6.0_18

Maybe the change cause the reason, but I would have thought the installer would be smart enough.
0
 
mahomeCommented:
Something is wrong with your classpath. Did you set JAVA_HOME ?
0
 
areyouready344Author Commented:
No i didn't set the JAVA_HOME, how do i do that? thanks
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
areyouready344Author Commented:
here's the output of my environment variables

C:\myJavaClasses>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Owner\AppData\Roaming
com.adobe.versioncue.client.applocale=en_US
com.adobe.versioncue.client.appname=AdobeDrive
com.adobe.versioncue.client.appversion=1.0.0
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=OWNER-PC
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Owner
LOCALAPPDATA=C:\Users\Owner\AppData\Local
LOGONSERVER=\\OWNER-PC
NUMBER_OF_PROCESSORS=2
OnlineServices=Online Services
OS=Windows_NT
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\jdk1.6.0_18\bin;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PCBRAND=Pavilion
Platform=MCD
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 23 Stepping 10, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=170a
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
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\Owner\AppData\Local\Temp
TMP=C:\Users\Owner\AppData\Local\Temp
USERDOMAIN=Owner-PC
USERNAME=Owner
USERPROFILE=C:\Users\Owner
windir=C:\Windows
0
 
areyouready344Author Commented:
When I executed the jdk-6u18.windows-i586.exe file, I selected the option to change the installed destination path from c:\Program Files (x86)\java\jdk1.6.0_18 to c:\jdk1.6.0_18. Could this have caused this problem?
0
 
mahomeConnect With a Mentor Commented:
You alo can set JAVA_HOME on console, but then it is lost, after closing the console

SET JAVA_HOME=c:\jdk1.6.0_18

Open in new window

0
All Courses

From novice to tech pro — start learning today.