JDK and Eclipse not working properly - eclipse

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.

Related

Error Creating a new Glassfish 4 server with Oracle Tools for Kepler

I installed Oracle Tools for Kepler with no problem. But when I want to create a new server and fill in the directory to the server (which is valid, C:/glassfish4/glassfish), nothing happens. I can only click 'back' or 'cancel'.
attached image for better understanding
Thanks in advance
http://es.tinypic.com/view.php?pic=x3tkea&s=8#.U2jz6vl5NUU
http://es.tinypic.com/view.php?pic=2n0ldtu&s=8#.U2j1_Pl5NUU
This is really a weird error/bug/whatever. I have exactly the same setup on my home workstation and it works if I choose jdk1.7.0_55 or Default JRE as JDK in the dialog. It doesn't work when I choose jre7.
You can try to select Default JRE and see if this works.
Another option is to try a clean start of Eclipse. Edit the eclipse.ini file located in your Eclipse install directory and insert -clean as first line.
If you have downloaded a multi-language version of GlassFish 4, the problem may be related to that. You then may try it with the english only version.
If this also doesn't help you can also add the server runtime manually in the folder <WORKSPACE>\.metadata\.plugins\org.eclipse.core.runtime\.settings\ in a file named org.eclipse.wst.server.core.prefs (if it doesn't exist, create it). It should look similar to this:
eclipse.preferences.version=1
module-start-timeout=300000
runtimes=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<runtimes>\r\n <runtime id\="GlassFish 4.0" location\="C\:/glassfish4/glassfish" name\="GlassFish 4.0" runtime-type-id\="org.glassfish.jst.server.runtime.glassfish4" server_definition_id\="org.glassfish.jst.server.runtime.glassfish4" timestamp\="0" vm-install-id\="1399586723676" vm-install-type-id\="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType">\r\n <map key\="generic_server_instance_properties" sunappserver.rootdirectory\="C\:/glassfish4/glassfish" sunappserver.runtimeName\="GlassFish 4.0"/>\r\n </runtime>\r\n</runtimes>\r\n
(The format looks a bit weird with the \r\n but this should be correct.)
You have to change the vm-install-id in this configuration, look for the ID of your JDK in the file <WORKSPACE>\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.launching.prefs. There should be an entry with your JDK. Copy the vm-install-id from this entry.
Make sure to have the right path to your GlassFish installation in that file.
After saving the file, start Eclipse and try to create a new server. The runtime should then be available when you choose GlassFish 4.0.
See also:
How to run eclipse in clean mode? and what happens if we do so?

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.

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

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.

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.

How do you install JDK?

I have eclipse and I can test run java apps but I am not sure how to compile them. I read that I should type javac -version into my cmd.exe and see if it is recognized. It is not. So I went to sun's website and downloaded/installed JDK v6. Yet it still says 'javac' is an unrecognized command. What am I doing wrong?
Thanks!
UPDATE
OK after reading some replies it seems like what I am trying to do is create a .jar file that can be ran on another computer (with the runtime). However I am having trouble figuring out how to do that. This might be because I am using Flex Builder(eclipse), but I added the ability to create java projects as well.
Thanks
UPDATE
OK I do not want to make a JAR file, I am not trying to archive it...the whole point of making a program is to send it to users so they can use the program...THAT is what I am trying to do...why is this so hard?
To setup Eclipse to use the JDK you must follow these steps.
1.Download the JDK
First you have to download the JDK from Suns site. (Make sure you download one of them that has the JDK)
2.Install JDK
Install it and it will save some files to your hard drive.
On a Windows machine this could be in c:\program files\java\jdk(version number)
3.Eclipse Preferences
Go to the Eclipse Preferences -> Java -> Installed JREs
4.Add the JDK
Click Add JRE and you only need to located the Home Directory. Click Browse... and go to where the JDK is installed on your system. The other fields will be populated for you after you locate the home directory.
5.You're done
Click Okay. If you want that JDK to be the default then put a Check Mark next to it in the Installed JRE's list.
You don't need a separate compiler, eclipse already compiles the application for you. What you probably want to do is to create an "executable" JAR file, which you can do in eclipse by selecting File->Export->Runnable JAR file.
Note, however, that the resulting JAR file is not a "real" (i.e. Windows binary) executable - it still needs a JRE installed on the target computer. There isn't really a way to create windows binaries; that's not how Java works. On the upside, it will work without recompilation on a Linux or MacOS machine (if it has a JRE installed).
javac is located in the "bin" folder of your JDK installation. In order to run it you must either use full path or add this directory to your systems search path via the Control Panel.
If you installed to c:\program files\java\jdk1.6.0 your call will have to look like this:
c:\> "c:\program files\java\jdk1.6.0\bin\javac" -version
Umm, eclipse is an IDE, it compiles things as you go. You don't need javac.
If you have Eclipse installed and you can write new java apps from within it, your compilation should work already..
Eclipse automatically builds/compiles your system when you're saving new Java files. Just try to write a new simple Hello world app, printing something to the console (just type sysout and Ctrl+Space inside Eclipse)
Eclipse automatically compiles all project in the workspace. YOu can disable this option if you like under Project->Build Automatically.
A JAR file can function as an executable, when you export your project as a JAR file in Eclipse (as Michael Borgwardt pointed out) you can specify what's the executable class, that meaning which one has the entry point [aka public static void main(String[] args)]
If the user installed the JRE he/she can double-click it and the application would be executed.
EDIT: For a detailed explanation of how this works, see the "How do I create executable Java program?"
Eclipse to use the JDK you must follow these steps.
1.Download the JDK
First you have to download the JDK from oracle site.
Download link - > https://www.oracle.com/technetwork/es/java/javasebusiness/downloads/index.html
2.Install JDK
Install it and it will save some files to your hard drive. On a Windows machine this could be in c:\program files\java\jdk(version number)
3.Eclipse Preferences
Go to the Eclipse Preferences -> Java -> Installed JREs
4.Add the JDK
Click Add JRE and you only need to located the Home Directory. Click Browse... and go to where the JDK is installed on your system. The other fields will be populated for you after you locate the home directory.
5.You're done
Click Ok. If you want that JDK to be the default then put a Check Mark next to it in the Installed JRE's list.