Error: Cannot run program "jar": CreateProcess error=2, The system cannot find the file specified - eclipse

When I run my BlackBerry project in Eclipse, I get the following error:
Error: Cannot run program "jar": CreateProcess error=2, The system cannot find the file specified
How is this caused and how can I solve it?

Finally I get the solution .copy the jar.exe from java bin folder and paste to the jre bin folder.

you can solve this problem by following setting
Right Click My Computer -> Select Properties-> Select AdvancedSystem Settings Tab -> Environment variables
Click on new button and Add
Variable Name : JAVA_HOME
Variable Value : C:\Program Files\Java\jdk1.7.0\
note jdk not jre

I tried several of the posted methods, the important step seemed to be setting the correct system path (the "Path" environmental variable) to have included a folder that pointed to the relevant jar.exe. The variable changed from X to X + ;C:\Program Files\Java\jdk1.7.0_03\bin; you need to make sure the jdk folder part is relevant to your version, which I overlooked.
The reason for my answer is to add the step I missed; which is to restart Eclipse! I tried running it a few times, but after closing and reopening it the project packaged correctly. It might not have been obvious to do this.

i think you need to set jarfile path.

From the BlackBerry Support Forums:
first thing is to check that the JDK is installed, and that the PATH
is set correctly. Open a command line window, and run the "jar"
command.

Set the Environment variable correctly (under path set till jdk->bin)
In your Eclipse Installed JREs make sure you are pointing till JDK folder and not JRE

The Solution is: Open My computer, right click > select properties > go to advanced > go to System environment variables > under PATH add this one:
c:/Program Files/Java/jdk1.7.0_03/bin
Close and reopen Eclipse and thats it...
NOTE: jdk1.7.0... is for the java version you have installed on your computer

This error comes because of Jdk1.7.
So try 1.6 and set path to bin folder.
It works for me...

I was developing an app for BB JDE 5.0 and I had the java JDK 1.7. I was going crazy because I tough everything was ok. Then I realize that for JDE 5.0 I needed JDK 1.6. Installed it from here Java SE Development Kit 6 Update 45 changed the environment path and my problem was solved!. :)

Adding C:\Program Files\Java\jdk1.8.0_131 to JAVA_HOME and C:\Program Files\Java\jdk1.8.0_131\bin to Path in System Variables within Environment Variables wasn't sufficient.
Turns out, you need to add those two variables and their respective values to both user and system variables within environment variables.
I added the following to BOTH User variables as well as System variables in Environment Variables:
Variable: JAVA_HOME
Value: C:\Program Files\Java\jdk1.8.0_131
Variable: Path
Value: C:\Program Files\Java\jdk1.8.0_131\bin
That worked for me !

This worked for me:
Project JDE 5.0
OS: Windows 8.1 x64
This PC > Properties > Advanced System Settings > Environment Variables:
Added the following:
Path: C:\Program Files (x86)\Java\jdk1.7.0_25\bin;C:\Program Files (x86)\Java\jdk1.7.0_17\bin;C:\Program Files (x86)\Java\jre7\bin
I know the above is similar but thought id post what worked for me anyway as it reinforces the above answers :)
NB to restart eclipse.

Related

JDK and Eclipse not working properly

Okay, so i wiped my PC clean today. Upon attempting to install Eclipse and the JDK i hit a snag.
I install the "ADT Bundle" from android developers.
I install the JDK to the default path
When i try to open Eclipse, it cannot find my JRE (which from what i understand comes in the JDK which i downloaded from the oracle website). I know it is properly installed because i can navigate to the install path and run java programs using the exe.
iv heard something about modifying environment variables to get it to find it but nothing has worked... i dont have a "PATH" variable listed.... i do have a "Path"... but changing either one does nothing to fix the problem... I have done this installation many times and it SHOULD be working...
any help on the subject would be greatly appreciated.
Since you wiped it clean, have you tried downloading Java Runtime Environment again (maybe you wiped it too)
The solution to this problem is such:
The "Path" enviroment variable needs to be under -user variables- NOT system variables
make a new user variable named "Path" and set the value to the absolute path of the java compiler
for me it was something like C:\Program File\Java\JDK1.7\bin
that should fix the problem of eclipse not finding the JDK/JRE...
if it complains about "JNI" then you need to make sure you are running the JDK and eclipse as the same achitechture (64bit java wont work with 32bit eclipse)
The "Path" environment variable needs to be defined or updated. If you are working in Windows 8 then you can navigate by following these steps:
Open > File Explorer
Right Click "Computer"
Select "Properties"
On the left hand side select "advanced system settings"
Under the "Advanced" tab, select "Environment Variables"
Locate the Path directory in the list under System
Edit the directory by entering a semi-colon after the last entry and then manually typing the location of your Java directory.
After the full address is entered, (Should look similar to --> C:\Program File\Java\JDK1.7\bin) click "Ok" on the screen to save your changes.
Something to keep in mind while updating your path. Make sure that you direct the path to the compatible version. If you downloaded the 64 bit eclipse, choose the 64 bit Java. If you do not remember the Eclipse version you downloaded, check your download file name against the files offered on Eclipse's website. If you follow these steps Eclipse should open up without a problem.

Ant "JAVA_HOME does not point to the JDK" - but it does

I cannot run my Ant build.xml since I updated to java 1.7.0_52 (or there about). I have been running it for years through Eclipse locally on my Windows 7 laptop - but with this latest jave jdk update somethings different (?).
BUILD FAILED
C:\workspace\WaterAspectsModel3\build.xml:329: 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.
It is currently set to "D:\Morten\Java\jdk1.7.0_52"
This is my jdk! So JAVA_HOME is pointing to a jdk (as is also clear from the error message). I have my JAVA_HOME with bin folder in my path as always. I've configured Eclipse - external tools configuration - with a JRE pointing to the same D:\Morten\Java\jdk1.7.0_52 (through "Separate JRE" setting). And I've tried a number of other configurations - all without luck.
I've been reading the tonnes of answers on lists here and other places and think I've tried all suggestions. Most seem to be cases where JAVA_HOME actually points to a jre and just needs to be corrected to jdk or there's a ";" in the path or something like that. None of these seem to apply in my case.
Any suggestions?
I was having the same message when running ANT through Eclipse.
What worked for me:
In Eclipse, access the menu: "Window -> Preferences";
Access "Ant -> Runtime", at the tree;
Access the Classpath tab;
Expand the "Global Entries" item;
Inside Global Entries, the path to tools.jar was wrong. It was pointing to an older version of Java;
I removed the wrong entry and added the correct one with "Add External Jars" button. It worked.
The solution
"Had to copy C:\Program Files\Java\jdk1.6.0_10\lib\tools.jar to C:\Program Files\Java\jre6\lib\ext" from here was great helpful and worked for me.
The real message is that Ant can't find com.sun.tools.javac.Main.
Which, together with the fact that the latest "Sun" (Oracle) JDK is 1.7.0_13 (or maybe _14, but definitely not the "_52" that your install dir indicates), makes me think that you're not using a distribution that Ant recognizes. You can verify this by running jar tvf $JAVA_HOME/lib/tools.jar, and looking for that class.
The Ant Manual talks about ways to work with different compilers. Since I've only used "Sun" compilers, I'm afraid that I can't give you any pointers.
Edit: you could also try setting fork="yes" in your build file. This should run the compiler executable rather than trying to invoke the compiler class.
Try adding JAVA_HOME\bin to your env PATH .
Add JAVA_HOME to Eclipse-Preferences-Java-Build Path-Classpath Variables.
Sorry for the unearthing,
I had the same problem, my solution doesn't need any modification in environment variables, and works for a recent JDK where the tools.jar can't be found.
Just go in the small down-arrow next to the ant run button
Then click "Configure external tools"
Then in JRE tab
Select a JDK installed on your computer, not a JRE, no problems if the selected JDK is not the same JDK/JRE as in your project.
It should be work now.

Unable to start Eclipse -- can't open \Java\jre6\lib\i386\jvm.cfg

could not open C:\Program Files\Java\jre6\lib\i386\jvm.cfg
is the error coming when i am trying to start eclipse ide.
my C:\Program Files has
jdk1.6.0_14
jdk1.6.0_17
jre6
folders.
path is set to
PATH: C:\Program Files\Java\jdk1.6.0_17\bin
what is the problem
i have seen this link but it is not solving my problem
can't find JRE in the JDK
I had similar problem on a Windows machine. I had moved my Java directory from inside "Program Files" (the space in the directory name was giving me trouble) over to c:\
I set all my PATH variables to the new location, restarted the machine and thought that would be enough. Nope
java -- version
Error: could not open `C:\Program Files\Java\jre1.8.0_66\lib\i386\jvm.cfg
This solution came from the good folks over at coderanch
Start regedit (just type "regedit" into the Run program) and work your way down to HKEY_LOCAL_MACHINE > SOFTWARE > JavaSoft
There you will find several different java directories
Java Development Kit
Java Plug-in
Java Runtime Environment
Java Update
Java Web Start
In each directory you'll find different directories for the different version of java (esp. Java Web Start). Open each and every one and you'll see that your old path is still listed. Double click the Name (left column) of the listing and manually type in the new path.
Open a new terminal and type in Java - version and you should be fine.
This problem can show up if you initially install Java in the default location (C:\Program Files) and then later re-install into another location.
The default installation copies java.exe, javaw.exe and javaws.exe to C:\Windows\System32. If you are in this situation and delete these files it will likely solve your issue.
(Thanks to Jay: http://jaykhimani.blogspot.com/2012/09/error-could-not-open-cprogram.html)
Problem: Eclipse Neon error: "C:\Program Files\Java\jre1.8.0xx.xx\jvm.cfg"
Solution Win7 Pro: System Properties > Enviorment Variables > System Variables > Path > Edit > #make sure the current JAVA directory appears first in the path if more than 1 JAVA directory exist.
In the path that follows, I moved "C:\ProgramData\Oracle\Java\javapath" behind the current directory "C:\Program Files\Java\jdk\bin;C:\Program Files\Java\jre\bin" > save
Path
C:\Program Files\Java\jdk\bin;C:\Program Files\Java\jre\bin;C:\apache-maven-3.5.0\bin;C:\ProgramData\Oracle\Java\javapath
I also had this problem and was having trouble finding a solution, but now I did!
If you uninstall your current running jre version and then install higher one you are good to go.
I was using jre1.6 when I had this problem but after installing 1.7 it was solved!
I recently got the same problem on my Windows 7. The issue was that two different paths were specified for Java in the path environment variable. This can be checked as follows.
On the command prompt, run the following command:
> where java
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe <br/>
C:\Program Files\Java\jdk1.8.0_192\bin\java.exe
The first one was the cause of the issue and removed it from the path.
Eclipse is working now without re-installation.
Note: The environment vars have been as follows always:
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_192
JRE_HOME=C:\ProgramFiles\Java\jdk1.8.0_192\jre
The problem is that your eclipse cant find jre.Just copy and paste your jre folder into eclipse folder and then start eclipse.Delete environment variable.
What worked for me was to go back to the Java webpage and download the Java jre instead of the jdk, since that is what the stupid computer is now looking for. Then open the C: Program Files>Java and make sure you see jre7 instead of jdk.
RS
Have a simpler solution:
Check your PATH. Most likely it is referring to incorrect java.exe. This started happening to me when I installed OS patch. In process of checkpoint etc, PATH got modified. Once I corrected it (using Environment Variables...), it worked immediately.
Try putting below line in your eclipse/STS -STS.ini file
-vm
C:\Program Files\Java\jdk1.8.0_121(your JDK version)\bin\javaw.exe
Put it at the top of the file.
Most probably it will work.
Sometimes putting javaw.exe in eclipse folder also work (where eclipse.exe is there)
This is an old post, but what solved my solution was editing the `eclispe.ini' file to include the correct path to the JDK.
Building off of what Lars answered, I did reinstall Java, so that may have been the source of the issue. Reglardless, this is the solution that worked for me. I did not have to delete any files from C:\windows\system32, however. I merely told eclipse to look in the new Java installation directory.
These docs indicated I needed to specify the path to the VM:
-vm
C:\Java\jdk1.7.0_25\bin\javaw.exe
This problem mainly occurs when we install new jre or jre gets updated automatically since jdk version and jre version are different and path variable i.e. JAVA_HOME contains jdk path with version included in it . Eclipse might be using that to generate the jre path name for the said file.
I did workaround i.e. changed name of jre folder to the older version e.g.
jre1.8.0_191 is after installing update and
jre1.8.0_60 was before update.
I renamed jre1.8.0_191 with jre1.8.0_60 to solve the issue
I had faced similar problem. Environment variable path problem
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_192
Set the Environment variable after going
Control Panel\All Control Panel Items\System and select Advanced System Settings then set Environment Variables
In System Variables add a new variable JAVA_HOME and variable value = C:\Program Files\Java\jdk1.8.0_192, the path of the jdk file in your system.
and %JAVA_HOME%\bin in the path of the system variables.
Hopefully the problem will solve.
After doing this It works fine for me.

Eclipse is not starting

Eclipse starts from terminal but when i try to start it from gui then it says java runtime environment don't found.
Environment variables are:
JAVA_HOME="/opt/jdk1.6.0_20"
PATH=$PATH:"/opt/jdk1.6.0_20/bin"
And one more thing so far i normally copy jre folder from jdk to eclipse directory, which works fine but what is actual way. i mean this won't be standard way to do that.
Thanks in advance
And one more thing so far i normally
copy jre folder from jdk to eclipse
directory, which works fine
No, this is not necessary or desirable. You should not have to do any such thing.
If you open up a command shell and type "java -version", what comes back?
Edit eclipse.ini (from the Eclipse folder) and add the following at the beginning:
-vm
C:/Java/jdk1.6.0_22/bin
where C:/Java/jdk1.6.0_22/bin should be your path to the java bin directory.
Keep it on two lines.
Well the reason eclipse won't start from GUI despite of the fact that environment variables are set, is:
You have set the variable in bashrc or bash_profile, these two are for the specific logged in user, but you also need to set in etc/profile which is for all the users.
So once you set the PATH and JAVA_HOME in etc/profile it will launch from GUI.
Worked for me! ;)
Faced the same problem and the suggestion addressed my problem!
After setting /etc/profile as indicated in the link below, I logged out and logged back in for GUI based Eclipse to work.
http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/

Eclipse just does not start up

I recently uninstalled and then reinstalled Java on my machine and ever since, Eclipse just does not start up. I find this weird, because I uninstalled a different version of Java from the one that I use. I modified the eclipse.ini file, by adding the following:
-vm
C:\Program Files (x86)\Java\jre1.5.0_15\bin\javaw.exe
This made no difference. I then tried to reset the JAVA_HOME variable and I tried both these things again, after reinstalling (well, unzipping) Eclipse again. None of this made any difference, which is why I'm posting this question. Can someone help me out here?
You need to make sure that the path to javaw.exe is in %PATH% environment variable. Basically:
%PATH% = %PATH%;c:\path\to\jre\bin
You can configure this in the environment variables configuration and you can verify this by opening a command prompt and test if java is recognized as a command from inside an arbitrary path.
The %JAVA_HOME% should by the way point to the JDK's /bin folder, not the one of the JRE. Regardless, this environment variable is ignored by Eclipse since it comes with its own compiler.
I uninstalled all the versions of Java I had installed and installed them again. I also deleted Eclipse and downloaded that again. Following this, I edited the eclipse.ini file to include the path the javaw.exe, as I mentioned in the question. Everything works fine now.