Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Miss Michelle. Heigardt - 06 Feb 2006 18:20 GMT
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>
Gordon Beaton - 06 Feb 2006 18:27 GMT
> com.sun.tools.javac.Main is not on the classpath.
> Perhaps JAVA_HOME does not point to the JDK
[quoted text clipped - 6 lines]
> 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

Signature

[  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

Miss Michelle. Heigardt - 06 Feb 2006 19:17 GMT
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
Gordon Beaton - 06 Feb 2006 19:49 GMT
> 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

Signature

[  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

rsch - 07 Feb 2006 07:45 GMT
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?
Roedy Green - 07 Feb 2006 12:51 GMT
On 6 Feb 2006 10:20:10 -0800, "Miss Michelle. Heigardt"
<michelleheigardt@hotmail.com> 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.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.