com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK

Discussion in 'Java' started by Miss Michelle. Heigardt, Feb 6, 2006.

  1. Hallo newsgroup, I am getting the error

    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK

    JAVA_HOME does point to my JDK. My Tomcat works with no problem. My
    Apache2 works with no problem. But I cannot compile. I am logged onto a
    free Debian 3.1 system as root. You can see at the bottom I am using
    Java 1.4 and both java and javac can be run from the command line
    without problem. Searching in Google there are lots of talk on
    tools.jar but I dont think this is for me as my Tomcat & Apache2 work.

    What shall I look for now? What shall I do?
    Thank you

    Michelle




    deb31Test:~/t9/v876/samples/jpetstore#echo $JAVA_HOME
    /usr/local/lib/jdk
    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore# ls /usr/local/lib -l
    total 16
    drwxrwxr-x 9 root src 4096 Aug 27 01:51 j2sdk1.4.2_08
    lrwxrwxrwx 1 root staff 28 Aug 27 01:55 jdk ->
    /usr/local/lib/j2sdk1.4.2_08
    drwxrwsr-x 3 root staff 4096 Jan 16 08:56 python2.3
    drwxrwsr-x 3 root staff 4096 Jan 6 11:27 site_ruby
    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore# find / -name tools.jar -print
    /usr/lib/j2se/1.4/lib/tools.jar
    /usr/local/lib/j2sdk1.4.2_08/lib/tools.jar
    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore# ls -la
    /usr/local/lib/j2sdk1.4.2_08/lib/tools.jar
    -rw-r--r-- 1 root root 5092686 Jan 11 15:19
    /usr/local/lib/j2sdk1.4.2_08/lib/tools.jar
    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore# ant build
    Buildfile: build.xml

    build:
    [javac] Compiling 73 source files to
    /t9/v876/samples/jpetstore/.classes

    BUILD FAILED
    /t9/v876/samples/jpetstore/build.xml:76: Unable to find a javac
    compiler;
    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK

    Total time: 4 seconds

    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore# java -version
    java version "1.4.2_08"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
    Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)


    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore#
    deb31Test:~/t9/v876/samples/jpetstore# javac
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is
    doing
    -deprecation Output source locations where deprecated
    APIs are used
    -classpath <path> Specify where to find user class files
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -d <directory> Specify where to place generated class
    files
    -encoding <encoding> Specify character encoding used by source
    files
    -source <release> Provide source compatibility with specified
    release
    -target <release> Generate class files for specific VM
    version
    -help Print a synopsis of standard options


    The line in my build.xml says

    <mkdir dir="${build.dir}"/>
    <javac destdir="${build.dir}" source="1.4" target="1.4" debug="true"
    deprecation="false" optimize="false" failonerror="true">
    <src path="${src.dir}"/>
    <classpath refid="master-classpath"/>
    </javac>
    Miss Michelle. Heigardt, Feb 6, 2006
    #1
    1. Advertising

  2. On 6 Feb 2006 10:20:10 -0800, Miss Michelle. Heigardt wrote:
    > com.sun.tools.javac.Main is not on the classpath.
    > Perhaps JAVA_HOME does not point to the JDK
    >
    > JAVA_HOME does point to my JDK. My Tomcat works with no problem. My
    > Apache2 works with no problem. But I cannot compile. I am logged
    > onto a free Debian 3.1 system as root. You can see at the bottom I
    > am using Java 1.4 and both java and javac can be run from the
    > command line without problem. Searching in Google there are lots of
    > talk on tools.jar but I dont think this is for me as my Tomcat &
    > Apache2 work.


    What do Tomcat and Apache have to do with it?

    Regardless of what you think, you do need tools.jar in your classpath
    if you want to use the compiler classes (not javac) from within your
    java application (look for it in e.g. $JAVA_HOME/lib).

    Read more here:
    http://java.sun.com/developer/JDCTechTips/2003/tt0722.html

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Feb 6, 2006
    #2
    1. Advertising

  3. Thank you for your reply Gordon.

    > What do Tomcat and Apache have to do with it?
    >


    They do show that my Java is not broken and Java works with other
    applications without a problem.

    > Regardless of what you think, you do need tools.jar in your classpath
    > if you want to use the compiler classes (not javac) from within your
    > java application (look for it in e.g. $JAVA_HOME/lib).
    >


    I have read the online manual and it says that tools.jar is needed in
    the classpath. And tools.jar is in my classpath (see it in my first
    post with all the environment variables). This is why I do not
    understand why it won't compile and write in this news group.

    Thank you
    Michelle
    Miss Michelle. Heigardt, Feb 6, 2006
    #3
  4. On 6 Feb 2006 11:17:02 -0800, Miss Michelle. Heigardt wrote:
    > I have read the online manual and it says that tools.jar is needed
    > in the classpath. And tools.jar is in my classpath (see it in my
    > first post with all the environment variables).


    The only environment variable you show in your earlier post is
    JAVA_HOME, not CLASSPATH. However it seems that Ant adds the necessary
    tools.jar to your classpath if JAVA_HOME is set; perhaps you need to
    export it as well if you haven't already done so.

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Feb 6, 2006
    #4
  5. Miss Michelle. Heigardt

    rsch Guest

    Re: com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOMEdoes not point to the JDK

    Hello !

    > com.sun.tools.javac.Main is not on the classpath.
    > Perhaps JAVA_HOME does not point to the JDK

    ....
    > <javac destdir="${build.dir}" source="1.4" target="1.4" debug="true"
    > deprecation="false" optimize="false" failonerror="true">
    > <src path="${src.dir}"/>
    > <classpath refid="master-classpath"/>
    > </javac>


    If you are using ANT you must set JAVA_HOME.
    So ANT will search the Java-compiler in $JAVA_HOME/lib/tools.jar.
    Are you sure that JAVA_HOME is pointing to the Java SDK not to the JRE?
    rsch, Feb 7, 2006
    #5
  6. Miss Michelle. Heigardt

    Roedy Green Guest

    On 6 Feb 2006 10:20:10 -0800, "Miss Michelle. Heigardt"
    <> wrote, quoted or indirectly quoted
    someone who said :

    >Hallo newsgroup, I am getting the error
    >
    >com.sun.tools.javac.Main is not on the classpath.
    >Perhaps JAVA_HOME does not point to the JDK


    see http://mindprod.com/jgloss/onthefly.html

    You must put tools.jar on the classpath explicitly.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Feb 7, 2006
    #6
  7. Miss Michelle. Heigardt

    jayesch

    Joined:
    Nov 12, 2007
    Messages:
    2
    I faced the same problem. I created system variable by name JAVA_HOME and updated it with value c:\program files\java\jdk1.5.xxx . But yet I kept getting same error. I event checked it on command prompt if variable was set by typing echo %JAVA_HOME% and it showed me proper value. I played for a long time with eclipse class path, ant and other settings but no success. Finally age old remedy came to my rescue. I restarted my machine and it worked. @$@$% microsoft.
    jayesch, Dec 13, 2007
    #7
  8. Miss Michelle. Heigardt

    patelakhil

    Joined:
    Oct 2, 2008
    Messages:
    2
    Same issue is resolved as per below

    http : // www . drftpd.org / forums / viewtopic.php ? f=5&t=2978
    patelakhil, Feb 7, 2011
    #8
  9. Miss Michelle. Heigardt

    abbinv

    Joined:
    Apr 9, 2011
    Messages:
    1
    abbinv, Apr 9, 2011
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan
    Replies:
    0
    Views:
    4,981
    Stefan
    Nov 5, 2003
  2. Andrew Thompson

    com.sun.tools.javac.Main ..API docs?

    Andrew Thompson, Jan 4, 2004, in forum: Java
    Replies:
    13
    Views:
    4,674
    Andrew Thompson
    Jan 6, 2004
  3. Gabe
    Replies:
    3
    Views:
    1,050
  4. drunken_wizard
    Replies:
    1
    Views:
    11,391
    Tris Orendorff
    Mar 23, 2006
  5. Andrew Thompson
    Replies:
    5
    Views:
    4,299
    Chris Uppal
    Jul 23, 2006
Loading...

Share This Page