• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Kshitija Ambulgekar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
To solve this problem add tools.jar file in window->preferences->ant-> runtime .

Regards
K.Murali gopal
 
Kshitija Ambulgekar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Murli,

I added tools.jar.
But still not working .





Kshitija
 
prateek urmaliya
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have added tools.jar as Global Entries in your ANT Runtime Classpath ?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18153
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Murali gopal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added tools.jar in the Global entries of ant runtime. For me its
working.
 
prateek urmaliya
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sergio Adrian and welcome to Javaranch!

I'm confused as to why ANT would be running inside a Jboss instance, can you elaborate?
 
Sergio Adrian
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Akhilkumar Patel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Akhilkumar Patel, welcome to Javaranch and thanks for sharing a solution!
 
Pierre Soubourou
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Copy the Tools.jar into Tomcat/common/lib

then restart the server.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic