Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Gil Steidle
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48415
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48415
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you got a Java™ SE download anywhere? Try reinstalling that, into the same C:\java folder.
 
Campbell Ritchie
Sheriff
Posts: 48415
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . 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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahhh much nicer after I reinstalled JSE Dev Kit 6 Update 21.

Onto conquering servlets now!

Thanks!
 
Campbell Ritchie
Sheriff
Posts: 48415
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad we could help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic