This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Could not find the main class: com.sun.tools.javac.Main. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Could not find the main class: com.sun.tools.javac.Main." Watch "Could not find the main class: com.sun.tools.javac.Main." New topic
Author

Could not find the main class: com.sun.tools.javac.Main.

Gil Steidle
Ranch Hand

Joined: Nov 19, 2010
Posts: 30
I am no longer able to compile any java code. I was working on the JavaRanch Cattle Drive Servlets exercise and followed the J2EE SDK link to download page. I got the JavaEE 6 version. Since installing it I can no longer compile. I am stuck. Thanks for your help. I've been enjoying the cattle drive so far.

Here's the message and the java code:

C:\JAVA\MyApps>javac HelloWorld.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(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: com.sun.tools.javac.Main. Program will exit.




C:\JAVA\MyApps>java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)

Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
your "java -version" seems to be ok, what does "javac -version" print out? and which javac is in your user / system path?
Gil Steidle
Ranch Hand

Joined: Nov 19, 2010
Posts: 30
C:\JAVA\MyApps>javac -version
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/M
ain
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: com.sun.tools.javac.Main. Program will exit.



C:\JAVA\MyApps>path
PATH=c:\java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Citrix\ICA Client;C:\Program Files\Common Files\Roxio Shared\DLLShared;c:\Program Files\Attachmate\EXTRA!

If this matters, the J2EE SDK that I recently downloaded is installed in C:\glassfishv3



Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
Welcome to the Ranch

Why are you using com.sun packages? Those are liable to change between releases without warning; it is quite possible the Main class has been removed.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
Have you got a Java™ SE download anywhere? Try reinstalling that, into the same C:\java folder.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
. . . and I see it doesn't appear to be you who are using a com.sun class, but the command line.
Gil Steidle
Ranch Hand

Joined: Nov 19, 2010
Posts: 30
Ahhh much nicer after I reinstalled JSE Dev Kit 6 Update 21.

Onto conquering servlets now!

Thanks!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
Glad we could help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Could not find the main class: com.sun.tools.javac.Main.
 
Similar Threads
ClassNotFoundException at runtime
Problem with Hello World
NoClassDefFoundError
Packaging question
jdk7 & jdk6 coexist on windows XP