Command line Ant not recognised - java

** Edit ** I have summarized the solutions I found to this problem in this post.
I am installing Android into Eclipse which I have been using for Java for 2 years. As part of this I have installed Ant and also upgraded to JDK1.7.0
Per the Cordova get started guide, I now run command line tests by typing java to see if it is recognized, then ant.
java is recognized (thanks to Nikolay Ivanov's help in a previous question)
ant fails to recognise anything
I have ANT_HOME set to "c:\Developer\apache-ant-1.8.4"
My PATH variable includes "%ANT_HOME%\lib".
I have also tried %ANT_HOME%\bin and %ANT_HOME%.
The ant.jar file is in c:\Developer\apache-ant-1.8.4\lib
But "ant" on the command line is still un-recognised.
FWIW, I now restart my command line interface every time I make a change in my environmental variables...
** Edit, I have removed %ANT_HOME%\bin from my build path and replaced it with "C:\Developer\apache-ant-1.8.4\bin".
I now have a new error "Buildfile: build.xml does not exist! Build failed"

Path should include %ANT_HOME%\bin but not %ANT_HOME%\lib.

Related

unable to open my eclipse due to java error

I was using my eclipse in very well and fine condition before few days. after that, I tried to work on Netbeans IDE, but I configured the Java JRE separately and tried to work with maven with Netbeans. but since the day I added the JRE path value and started using Netbeans I'm completely unable to open my Eclipse.
Java was started but returned exit code = 1
this error is prompt after trying to open it.
Help...enter image description here
Inside eclipse folder open the file eclipse.ini in notepad or notepad++ you can find required java version mentioned like
-Dosgi.requiredJavaVersion=1
and add the following as last line. Before this, you have to close Eclipse (you can add your preferred jdk version).
-vm
Path-to-java11\bin\javaw.exe
Note there is linebreak between -vm and path After making changes, you can start eclipse. For more details, refer this link. https://wiki.eclipse.org/Eclipse.ini

Installing and using HDF5 for Eclipse on Mac OSx

I am trying to install and use the HDF5 libraires in eclipse in order to read and manipulate a dataset for my Big Data class.
I followed the instructions from the following website : http://www.hdfgroup.org/products/java/release/downloadsrc.html
At the end of the installation, after the command
ctest -S HDFJAVAMacCMake.cmake -C Release -V -O hdf-java.log
I get the following message :
100% tests passed, 0 tests failed out of 313
Total Test time (real) = 39.85 sec
[ERROR_MESSAGE]
Error in read script: /Users/fg/Downloads/build/HDFJAVAMacCMake.cmake
I don't understand why I get the Error in read script after every test passed.
Was the installation successful or not ? If yes, how do I manage to link the hdf5 libraries into my eclipse project ?
Thanks a lot for your time!
Okay, I managed to link and use the library in Eclipse. For those with the same problem, here is what I did.
After building the HDF-java software with cmake (as described in the link I provided), I still get the error message
[ERROR_MESSAGE]
Error in read script: /Users/fg/Downloads/build/HDFJAVAMacCMake.cmake
But everything has been compiled successfully (I still don't know why I get this message though).
Then, the following dmg appears in the build directory HDFView-2.10.1-Darwin.dmg (for version 2.10.1 of course). You need open it and drag it to your application folder. This "app" (right click, Show Package Content) contains the java libraries for HDF4 and HDF5, as well as the native librairies (.dylib for mac osx).
The paths are the following,
JARs files : /Applications/HDFView.app/Contents/Java
Native libs: /Applications/HDFView.app/Contents/Resources/lib
At this point, you can open Eclipse and go to the "Build Path Configuration" of your project and provide both the JARs and the native lib path.
Under the Libraries tab, you have to provide all the JARs contained in the first path I mentioned above. Then, go to the Source tab and you should see Native library location under your project. Simply give the second path I mentioned above.
Now you should be able to use the HDF libraries and compile your project without exception.
Hope this helps!

org.codehaus.groovy.grails.cli.support.GrailsStarter not found error

After updating from Grails 2.3.10 to 2.3.11 and updating the path variable to
export GRAILS_HOME=/Applications/grails/grails-2.3.11
When I run: grails I get the following error:
Error: Main class org.codehaus.groovy.grails.cli.support.GrailsStarter could not be found
I found the solution. If you go to the grails/bin folder and run grails from the command line you can close the console afterwards and when you open the console again the problem will be fixed.
Solution:
Make sure you have environment variable set correctly.
Go to grails/bin folder $cd /Applications/grails/grails-2.3.11/bin
Then run grails from command line $./grails
When you run this command, necessary files for your grails will be downloaded.
Close your terminal
Now check your grails version from terminal $grails -version
There won't be any errors.
You are probably still running grails 2.3.10.
You have to update GRAILS_HOME and you also have to update your path to use the new grails version, i.e. your path must include $GRAILS_HOME/bin.
The question and answers seems to be out-of-date. I have encountered the same problem but it has been fixed by replying the discussion here. The easiest way to resolve the issue is to run the following command:
chmod +x .sdkman/bin/sdkman-init.sh
which helped me out.
You could just use gvm to install your version then use it to manage your versions.
I'm using Grails installed with GVM, and I've also run into this issue after updating environment variables in the profile and sourcing in the new changes. I was able to fix the problem simply by closing and reopening the terminal.
You must update your jdk version.
I was using jdk1.8.0_11 and it resolved with jdk1.8.0_45.
I ran the below commands:
1. To set path to contain jdk 1.8.0_144 bin folder & Grails bin folder.
2. Set JAVA_HOME to jdk1.8.0_144
3. set GRAILS_HOME to Grails-2.4.3 folder.
And it worked !!!

Getting Error executing command and make sure you have ant installed and add to your path

I added all the paths that needed.
I read Android Platform Guide from Apache Cordova over and over again, And I just can't find the answer.
I have search similar problems in stackoverflow but it didn't help or the answer was for
ant that was not recognize at all in cmd.
Here is my cmd with the error:
"Error: ERROR : executing command and make sure you have ant installed and add to your path"
As you can see, 'ant -version' working just fine, but cordova just can't recognize it..
Please help me.
Ok I fix it by adding this line:
"C:\Windows\System32;C:\Windows\System;C:\Windows\System32\wbem;"
In Environments Variables -> edit "Path" variable and append this line inside value.
Done. :-)

Getting Error running javac.exe compiler message, while using Ant in Eclipse

When I run my Ant build in Eclipse, I'm getting the following error message and the Ant build fails.
Error Message: Error running javac.exe compiler
Line where the build stops:
<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.
I had the same problem and removed the attribute fork from javac and problem was gone.
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 solved this by checking my Environment Variables in my Windows 7. I found that JAVA_HOME is pointing to C:\ Program Files (x86)\Java\jdk1.6.0_31 when it supposed be C:\ Program Files\Java\jdk1.6.0_31. If you want to know how read this
If you are running ant in eclipse click run as --> Ant second option and choose JDK path and run the build again.
Try changing memorymaximumsize="1G" to memorymaximumsize="512M".
Try to free some main memory. Close memory-hungry programs, and stop memory-hungry processes if you can.
I've tried everything but nothing worked for me till I've set (fork='no' or fork='false' in your case) and worked for me perfectly
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.
I fixed the problem like this:
My Java home folder had the wrong path. It should have been C:\Program Files (x86)\Java\jdk1.5.0_15 but instead it was C:\Program Files (x86)\Java\jdk1.5.0_15\bin.
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!!

Categories