wood burning stoves
The moose likes JBoss/WildFly and the fly likes Unable to find a javac; Perhaps JAVA_HOME does not point to the JDK Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Unable to find a javac; Perhaps JAVA_HOME does not point to the JDK" Watch "Unable to find a javac; Perhaps JAVA_HOME does not point to the JDK" New topic
Author

Unable to find a javac; Perhaps JAVA_HOME does not point to the JDK

Kshitija Ambulgekar
Greenhorn

Joined: Aug 27, 2006
Posts: 24
Hi All,

We are using Ant inbuilt in Eclipse3.1. When we are trying to build the project, build is failing and we are getting following error:

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

Whereas JAVA_HOME is already pointing to java home directory. Also we added tools.jar in the classpath. But no use..

Can somebody help on this?
Murali gopal
Greenhorn

Joined: Oct 10, 2006
Posts: 8
Hi
To solve this problem add tools.jar file in window->preferences->ant-> runtime .

Regards
K.Murali gopal
Kshitija Ambulgekar
Greenhorn

Joined: Aug 27, 2006
Posts: 24
Hi Murli,

I added tools.jar.
But still not working .





Kshitija
prateek urmaliya
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
You have added tools.jar as Global Entries in your ANT Runtime Classpath ?


this message brought to you by .... PIE! .... it's yummy! ;)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17168
    
  27

I used to have this problem. There's a fix for it - it has to do with the fact that Eclipse is using a javac internally that may not be the same as the one that it gets when running Ant.

My memory is shaky on this, but I found the answer by googling. I think that I used to have to have something in build.xml to handle that, but I can't remember.

Don't forget, BTW, that the PROJECT classpath isn't the same as the ANT classpath. To set up an Ant classpath, right-click on the build.xml icon in the explorer, select Run As/Ant Build... and setup the classpath tab.

My default Ant classpath in eclipse shows all the jars in in ANT_HOME (default) and the following jars in "Additional Tasks & Support":

.../eclipse/configuration/org.eclipse.osgi/.../remoteAnt.jar
tools.jar - /usr/java/jdk1.5.0/lib/
and a SWT gtk Linux jar, since this is a Linux box.

The OSGI remoteAnt pathname has been shortened to show the important parts of it.


An IDE is no substitute for an Intelligent Developer.
Murali gopal
Greenhorn

Joined: Oct 10, 2006
Posts: 8
I have added tools.jar in the Global entries of ant runtime. For me its
working.
prateek urmaliya
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
I used to have this problem. There's a fix for it - it has to do with the fact that Eclipse is using a javac internally that may not be the same as the one that it gets when running Ant.

well you can select the JRE by going to the Window-->Preferences-->JAVA-->Editor-->Installed JRE .
You can change the default so it points to whatever your ANT is picking up (JAVA_HOME).
[ October 11, 2006: Message edited by: prateek urmaliya ]
Sergio Adrian
Greenhorn

Joined: Nov 18, 2010
Posts: 2
Kshitija Ambulgekar wrote:Hi All,

We are using Ant inbuilt in Eclipse3.1. When we are trying to build the project, build is failing and we are getting following error:

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

Whereas JAVA_HOME is already pointing to java home directory. Also we added tools.jar in the classpath. But no use..

Can somebody help on this?


Hi, I´m new here.. I see that error in the server.log from JBoss app server today.. but the server was running without problems before that..

more server.log
2010-11-17 09:14:59,344 ERROR [org.apache.jasper.compiler.Compiler] Javac exception
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
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:105)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:929)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:758)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)

The application is Ok now, only need to restart the JBoss app server.. but I can´t understand the origin of this problem..
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3275
    
    5

Hi Sergio Adrian and welcome to Javaranch!

I'm confused as to why ANT would be running inside a Jboss instance, can you elaborate?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Sergio Adrian
Greenhorn

Joined: Nov 18, 2010
Posts: 2
Martijn Verburg wrote:Hi Sergio Adrian and welcome to Javaranch!

I'm confused as to why ANT would be running inside a Jboss instance, can you elaborate?


Hi Martijn!, sorry for my very bad English..

I´m a web middleware administrator.. and this is not about a ANT, this is only a application running on JBoss and when I check the problem... the only message was that.

I don't have skill on java develop.. sorry.. maybe this place is not for me.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10441
    
176

Sergio, which version of JBoss AS do you use? And which version of Java? Have you set the JAVA_HOME while starting the server? What does it point to? And how do you start the server?


[My Blog] [JavaRanch Journal]
Akhilkumar Patel
Greenhorn

Joined: Feb 07, 2011
Posts: 1
I was facing same issue and it is resovled as per solution given in following link:

http://www.drftpd.org/forums/viewtopic.php?f=5&t=2978
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3275
    
    5

Hi Akhilkumar Patel, welcome to Javaranch and thanks for sharing a solution!
Pierre Soubourou
Greenhorn

Joined: Feb 16, 2011
Posts: 1
Had troubles when installing Wave (https://sites.google.com/a/waveprotocol.org/wave-protocol/code/installation)
I found the page http://ubuntuforums.org/showthread.php?t=217936&highlight=classpath
Elnur's comment:
http://ubuntuforums.org/showthread.php?t=217936&highlight=classpath
worked for me
suresh talluri
Greenhorn

Joined: Jun 09, 2011
Posts: 1
Copy the Tools.jar into Tomcat/common/lib

then restart the server.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10441
    
176

Suresh, welcome to the forums!

suresh talluri wrote:Copy the Tools.jar into Tomcat/common/lib

then restart the server.


That's not the right thing to do for various reasons:

1) This is JBoss AS. There's no Tomcat/common/lib
2) tools.jar isn't meant to be added there


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to find a javac; Perhaps JAVA_HOME does not point to the JDK
 
It's not a secret anymore!