<javac destdir="${classes.home}" debug="on" fork="true" memoryinitialsize="512M" memorymaximumsize="1G">
<classpath refid="classpath"/>
<src path="${source.home}"/>
</javac>
Has anyone faced a similar problem before? or does anybody know what's wrong here?
System Information: Eclipse Helio, JDK 1.5
–
I had the same problem and the issue was, in eclipse java.home was referring to JRE instead of JDK. I changed it and the build was successful. You can do the following to change it to JDK:
Preferences > Java > Installed JRE's > Add... For 'JRE Type' select 'Standard VM' > Next > Directory: select your JDK directory (instead of JRE) (in my case: C:\Program Files\Java\jdk1.6.0_16 ), press OK.
Now, you are back at 'Installed JRE's', select the JDK here also.
The below post helped in finding the solution.
JAVA_HOME points to the wrong place
If the accepted answer above doesn't solve the problem for you (as it didn't for me), after updating the java.home to JDK instead of JRE as suggested in the accepted answer above, Go to Run -> External Tools -> External Tools Configuration -> select your build.xml on the left menu -> select JRE tab -> select the JDK(from the dropdown) for Separate JRE radio button option -> Click Run.
This should fix the problem.
–
–
–
–
Maybe the javac problem is because "javac.exe" is not in your System PATH, please edit your system path and add your JDK's /bin directory to it to correct this problem.
Open a shell or command prompt and try typing: javac to check if the system path is set correctly.
–
–
–
–
Configuring eclipse to point to JDK instead of JRE did not work for me.
With further investigation, I solved this problem by stopping the build process from forking.
In your build.xml, remove the attribute fork
from <javac>
tag.
I faced the same problem, and here is my advice, maybe it will help someone.
In fact, message Error running javac.exe compiler
means that something went wrong. The question is, what exactly. When Ant runs javac
task with fork="true"
flag, it doesn't print any error details. In my case, it didn't print them even after I added verbose="true"
, as suggested here. Solution was to add -verbose flag to Ant command line:
ant -verbose
After this, Ant starts printing full error messages, so you are able to fix a problem.
The accepted answer didn't work for me.
But right-clicking in Ant and setting the Java Runtime Environment (JRE) to the Jave Development Kit (JDK) worked for me.
Abhi Rampal's answer is the step by step the same way I solved the problem on my eclipse.
Go to Run -> External Tools -> External Tools Configuration -> select your build.xml on the left menu -> select JRE tab -> select the JDK(from the dropdown) for Separate JRE radio button option -> Click Run.
I removed fork="true" and I got past that piece of code. What might be interesting to those of you who have this problem is that now, at that line, I get the output:
'Since fork is false, ignoring memoryMaximumSize setting.'
So it may be an issue with memoryMaximumSize if you need to keep your fork="true" setting, as suggested above.
We hit the same issue on a windows build machine whereas locally (on a unix machine) everything worked out. Fork = true didnt helped either, it resulted in a Process fork failed exception also only on the build server
Research
After some research, we had a clue that the classpath might be too long.
We recreated the exact folder structure locally on a windows machine and we hit the same issue and we saw that the classpath was way too long (we used -v and -d for details how long it was) and this was the cause of the error.
Solution
The solution was to create a jar, which contains only the manifest with all the libraries, see this answer for more details
For me it was backup libs inside WEB-INF/lib directory.
I had multiple lib directory inside the main lib. And the classpath was including them all causing the javac command to become too long.
I removed those directories and it worked for me.
That's a very simple issue. The base directory path has to many subfolders that leads to the actual folder. For e.g.:
/folder1/folder2/.../.../folderN/{project}
Decrease the base directory path size and it will compile easily.
For e.g.:
D:/{project}
Thank me later.
Most of the times, long path to project folder makes the build fail. That's what was found always even when running from Command Line. Just shorten your path to:
{Drive Letter}/{Checkout Project Folder}
and ant commands will surely compile the java JDK.
You need to see the logs for the root cause of the error. Add the runtime argument "-verbose" while running the ant script and it will show the stack trace of the error.
For me, it was throwing for "Error running javac compiler ant The filename or extension is too long ..."
I solved it by, installing java in a separate location that is shorter in length, like D:/java/jdk1.8_251.
Also, you can try shortening the eclipse workspace path to a shorter one.
Hope it helps!!
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.