Results 1 to 7 of 7
  1. #1
    JimmyD is offline Member
    Join Date
    Oct 2011
    Location
    New Jersey
    Posts
    44
    Rep Power
    0

    Default Can't run javac after installing jdk 1.6

    I need to update the java on one of my server to 1.6. Everything is running fine under jdk 1.5. And I looked through most of the core code, they should work on 1.6 as well. I needed 1.6 to develop some new features. Therefore I tried to install jdk1.6 update 30. After installing and pointing the path variable, I encountered the following error when I tried to re-compile all my files:

    root> 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(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.


    I tried to install 1.6 update 26, but the problem persists. Reverting back to 1.5, javac compiles the codes properly again.

    I googled up the error online, but I don't really understand most of the replies or proposed solution. The response online sees to say that this is more of a server error that relates to Tomcat and JSP? I am just a regular java programmer without too much working knowledge on either tomcat or JSP yet. Could anybody enlighten me on this error?


  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,004
    Blog Entries
    7
    Rep Power
    20

    Default Re: Can't run javac after installing jdk 1.6

    Javac.exe (on a MS Windows machine) is just a small wrapper that fires up the JVM and tries to make the JVM run a Java class: com.sun.tools.javac.Main; if that wrapper succeeds (you can test it by typing 'javac YourSource.java') everything is fine. Something else tries to run that com.sun.tools.javac.Main class directly but it's looking at the wrong place; probably caused by a previous installation of your JDK and/or an incorrect environment variable setting (look for something like JAVA_HOME in your environment).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    JimmyD is offline Member
    Join Date
    Oct 2011
    Location
    New Jersey
    Posts
    44
    Rep Power
    0

    Default Re: Can't run javac after installing jdk 1.6

    Hey Jos,

    Thanks for replying my question again! Some of the things you said rings some bells~

    1. Versions.. The server is built in old days, we initially used java 1.4, but we installed 1.5, and then now 1.6.
    So all these version are present. We simply changed all environmental var to the jdk folders..

    2. JAVA_HOME.. before we did not even set such an env var.. it's only when I needed to use Ant to build .jar files, I set up Ant on the server and thus set up the ANT_HOME and JAVA_HOME env var.

    for path, I set to jdk_1.6\bin , for JAVA_HOME, i set to jdk_1.6 folder.

    I didn't see anything wrong with such setting..

    Maybe with these details, you could direct me a bit further?

  4. #4
    JimmyD is offline Member
    Join Date
    Oct 2011
    Location
    New Jersey
    Posts
    44
    Rep Power
    0

    Default Re: Can't run javac after installing jdk 1.6

    Hi Jobs,

    I've figured the problem already.. It seems to be an installation problem:

    When I installed java 1.6 (update 26) before, I installed the JRE in the same folder as the JDK when the installation prompts me. That might have overwrote some of the essential files in the original JDK folder..

    Now I just separated jre and jdk into 2 different folder and everything is back to normal.

    It seems that before 1.6, i.e. the 1.5 and 1.4, you can put jre in the same folder as jdk and the java environment would be fine. I do not have a deeper understanding on this matter though.. I learned java with 1.6..

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,004
    Blog Entries
    7
    Rep Power
    20

    Default Re: Can't run javac after installing jdk 1.6

    As far as I know, if you download and install the JDK, it installs a JRE with it. Both are installed in separate directories next to eachother.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    shaikhshahidg is offline Member
    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Default Re: Can't run javac after installing jdk 1.6

    Hi Jimmy i am also facing similar kind of issue , will the option of re-installing of Java 6 JDK and JRE in different locations help me .

    Thanks


    Quote Originally Posted by JimmyD View Post
    Hi Jobs,

    I've figured the problem already.. It seems to be an installation problem:

    When I installed java 1.6 (update 26) before, I installed the JRE in the same folder as the JDK when the installation prompts me. That might have overwrote some of the essential files in the original JDK folder..

    Now I just separated jre and jdk into 2 different folder and everything is back to normal.

    It seems that before 1.6, i.e. the 1.5 and 1.4, you can put jre in the same folder as jdk and the java environment would be fine. I do not have a deeper understanding on this matter though.. I learned java with 1.6..

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Can't run javac after installing jdk 1.6

    Don't post to old dead threads and don't hijack another poster's thread. When you have a question, start your own thread -- they're free.

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Installing JDK 1.5
    By raahul456 in forum New To Java
    Replies: 7
    Last Post: 09-03-2009, 11:50 AM
  2. HELP installing JDK please!
    By trucutru in forum New To Java
    Replies: 9
    Last Post: 01-17-2009, 06:31 AM
  3. Help with JExcel installing
    By Webuser in forum New To Java
    Replies: 0
    Last Post: 12-02-2008, 05:55 AM
  4. installing j2s
    By ravjot28 in forum Eclipse
    Replies: 9
    Last Post: 06-27-2008, 11:10 AM
  5. Installing JMF
    By vinnieza in forum Eclipse
    Replies: 0
    Last Post: 05-04-2008, 07:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •