How to create Java 8 project in IntelliJ IDEA 13.1? - java

I want to try IntelliJ IDEA 13.1, so I've installed the enterprise edition for evaluation. Also, I have installed JDK8u11 64 bit. I am using Windows 8.1.
When I try to create new project, I need to select JDK. I am able to choose JDK7, but JDK8 is not accepted with message "The selected directory is not a valid home for JDK".
Based on "The selected directory is not a valid home for JDK" Android Studio I've set JAVA_HOME to point to C:\Software\Java\jdk1.8.0 where JDK8u11 is installed, with no effect. I have also run IntelliJ IDEA in Administrator mode, without success.
I'm a bit stuck here. Am I missing something?

A copy of my answer in the comments so that #tptak can graciously give me credit for the correct answer. Thanks.
Make sure the dir you select has the bin, jre and lib directories. Could you have a double jdk1.8.0 dir name (or some such thing) from an error when setting the install dir during install?

Related

Need help using IntelliJ and setting up a project SDK

When I try to run my program using IntelliJ it says I need a project SDK but when I try to set up a project SDK, it says "The Selected directory is not a valid home for this SDK"
This can happen when a java SDK is deleted, moved, or configured incorrectly.
Go into Project Structure (Ctrl+Alt+Shift+s)
On the left under Project Settings select Project
Now see the Project SDK: - it is likely red if cofigured incorrectly or it might say <No SDK>.
Firstly, just see if there is another SDK of appropriate java version in the drop down list you can use.
If not, you can use Edit button on an existing JDK to modify the JDK home path if it is wrong.
Or just press New... and JDK to set up a JDK that is already installed on your machine (e.g. C:\Program Files\Java\jdk1.8.0_72)
...if you have no JDK on your machine (be aware of the difference between a JRE and a JDK) then you'll obviously need to download and install that first

Android Studio doesn't find Java Development Kit (JDK)

I have installed Java 8 on my computer but Android Studio doesn't find it. When I execute the installer of Android Studio I only can see an screen in which I can see an introduction and when I press "Next" another screen it's displayed in which says:
We could not detect a Java Development Kit (JDK) v7 or newer on your system. Please browse to its path if known.
So I searched my JDK and when I press the button "Next" I get the following message:
Sorry, we still could not detect a valid JDK, which we need to proceed.
If setting your JDK path manually, make sure you have browsed to a parent directory that contains a "bin\java.exe" whose version reports 1.7 or higher when you run "java.exe -version".
After that, I go to the console and execute the command "java.exe -version". It gives to me:
java version "1.8.0_60"
So I don't know why it doesn't find my JDK. I also tried adding some Environment Variables:
JAVA_HOME: C:\Program Files\Java\jre1.8.0_60\
JDK_HOME: C:\Program Files\Java\jre1.8.0_60\
But it still doesn't find it. How can I fix it?
Note: I'm using Windows 10 as OS.
Thanks in advance!
I think your JAVA_HOME variable is set to the wrong thing. Mine is:
JAVA_HOME C:\Program Files\Java\jdk1.8.0_60
I also have a PATH variable set as follows:
PATH %JAVA_HOME%\BIN
I do not have a JDK_HOME variable.
Try that and see if it works.
(I recently installed Android Studio and had the same problem, even though I had Java 7 installed. So I downloaded Java 8 and manually updated the JAVA_HOME variable.)
I had the same problem when trying to install Android Studio bundle v2.1 (143.2915827-windows) on a Windows 10 machine with a JDK at a non-standard location (the JDK on a path containing spaces). After manually selecting the path, the installer would complain that it could still not find a JDK. I solved it by manually enclosing the selected path with double quotes by typing in the editable textbox.
This drove me nuts for a couple of days. I was not able to resolve the issue through the Android studio installer, but found a workaround:
Go to http://developer.android.com/sdk/index.html
Instead of downloading "Android Studio package" (the exe file), scroll down and select "SDK tools package" (the zip file).
This work perfectly and allows you to select all the packages you want to download, including the packages installed by the installer.
What worked for me. I recieved the same error message and went to directly install the java, without closing the installation of Android studio. then tried to find the path. so I closed out the window for Android Studio and Reopened the download file and it automatically detected it. This might not work for everyone but worth a try. easier then messing with everthing else.

Missing JRE in Eclipse in Mac OSX

I'm trying to run eclipse on my Mac OS X. I've been doing some Android programming on Eclipse lately, and today wanted to do some development on Java. However, to my surprise, Eclipse says there's no JRE/JDK installed. I don't know how this is possible, since my android projects have worked very well so far, and even now. I've tried the following items:
Checking java version through the Mac terminal. It says java version "1.8.0_20" is installed. Here's the screenshot.
I've checked the Java version through the Java Control Panel in System Preferences. Again, same thing:
I know that when there's no JRE visible in Eclipse, it can be manually entered through the "add" option under preferences > Java > Installed JREs in Eclipse. But although I can find the Contents folder in this path: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/home/contents, when I attempt to manually add this in Eclipse, the Java folder under users/library just doesn't show up. I have no idea why this is happening. Here are some screenshots, just in case:
As you can see, the Java folder just doesn't show up under Library in the above screenshot.
Lastly, I've also tried to hit "Search" in Eclipse (same place as "Add" in one of the screenshots above), but "Search" doesn't find anything at all.
I've gone through existing answers on SO which deal with similar problems. The only thing which I haven't done seems to be about setting a path variable, but they were all in Windows OS, so not sure if it applies in my situation.
I'd really appreciate any help on this.
Update 1: According to what has been pointed out so far, I tried copy-pasting the suggested path. But the error I get is: The home directory does not exist.
Here's the screenshot:
You are trying to find the JRE in a wrong Library directory as Library directory maybe present in more than one place. Just copy paste the jre path in 'jre home' input as
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/home/contents/Home/jre/
EDIT: To find where is your java installed on Mac, run the following command:
echo $(/usr/libexec/java_home)
it should return something like this:
/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
append jre to the end of this path to build JRE home path:
/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre

Can't get Eclipse to run with Java FX

Alright so basically, I'm trying to run Eclipse with JavaFX, but then it gives me this error:
You are not running your eclipse instance with Java7 or Java8. The JavaFX tooling is disabled because of this.Make Java7/8 the default system java or adjust your eclipse.ini to pass -vm pointing to your Java7/8 install.
In case you want to turn off this check open your preferences and go to General > Startup and Shutdown and uncheck 'JavaFX Tooling Java Check'
Now I know it isn't pointing to the right SDK, but I have no idea how to change it, since I'm kind of new to this this stuff. I've already downloaded JDK 7.40 as well. I'm also using Ubuntu on a virtual machine, if that even matters anyway. Can anyone help me, I'd appreciate it.
Pre-requirements:
Install Java™ 8.
Install Kepler SR2 (4.3.2) .
The Kepler is still not supporting Java8. What to do?
Open Eclipse
Help > Install New Software…
Enter the following URL into the ‘Work with’ field:
http://download.eclipse.org/eclipse/updates/4.3-P-builds/
Press ‘Enter’
Select category ‘Eclipse Java 8 Support (for Kepler SR2)’
Click ‘Next’
Click ‘Next’
Accept Licence Agreement
Click ‘Finish’
Now jre8 is correctly located.
Now configure JavaFx
Open Eclipse
Help > Install New Software…
Enter the following URL into the ‘Work with’ field:
http://download.eclipse.org/efxclipse/updates-released/0.9.0/site
Press ‘Enter’
Select category ‘Eclipse Java 8 Support (for Kepler SR2)’
Click ‘Next’
Click ‘Next’
Accept Licence Agreement
Click ‘Finish’
It looks like the default java on your system is not java7. What do you get when opening a shell and execute java -version? Solution is to:
A) make java7 the default java
B) start eclipse with -vm
Apparently, you have installed 32bit Eclipse and 64bit JRE/JDK on a 64bit OS. Please use 64bit Eclipse and the problem will be solved. Please make sure JAVA_HOME And JRE_HOME is present in environment variables.
I had the same issue. I tried re-installing Eclipse, but it wouldn't work. I had to completely remove the project and delete all the project files. After that, I re-started eclipse and created the project again. However, this time I made sure the project path included the Java FX library as shown in the screen shot.
Java Build Path
I did this while I was creating the project and then I was able to create the project without any issues. Give this a try.

How can I set the JDK NetBeans runs on?

I have the older NetBeans 6.7, NetBeans 6.9, and NetBeans 7.0, which used to run on jdk1.6.0_21 and jdk1.6.0_25. Now I've removed those JDKs and only have jdk1.6.0_26 and jdk1.7.0 left, but I still want to keep the older versions of NetBeans, but now when I run them, I get this message:
"Cannot locate java installation in specified jdkhome C:\Program Files (x86)\Java\jdk1.6.0_25
Do you want to try to use default version?"
I tried to find where it's looking for the "jdk1.6.0_25", and updated a few configuration files in "C:\Program Files (x86)\NetBeans 6.7" and "C:\Users\USER.nbi\registry.xml", and yet the message keeps coming. Where and what do I need to change to point it to C:\Program Files (x86)\Java\jdk1.6.0_26?
Thanks to Kasun Gajasinghe's tip, I found the solution in the "suggested" link. Update the following file (replace 7.x with your NetBeans version):
C:\Program Files\NetBeans 7.x\etc\netbeans.conf
Change the following line to point it where your Java installation is:
netbeans_jdkhome="C:\Program Files\Java\jdk1.7xxxxx"
You may need administrator privileges to edit netbeans.conf.
Go to Tools* → Java Platforms. There, click on Add Platform and point it to C:\Program Files (x86)\Java\jdk1.6.0_25. You can either set the another JDK version or remove existing versions.
Another solution suggested on the Oracle (Sun) site is,
netbeans.exe --jdkhome "C:\Program Files\jdk1.6.0_20"
I tried this on 6.9.1. You may change the JDK per project as well. You need to set the available JDKs via the Java Platforms dialog. Then, go to Run → Set Project Configuration → Customize.
After that, in the opened dialog box, go to menu Build → Compile. Set the version.
For those not using Windows, the file to change is netbeans-8.0/etc/netbeans.conf.
And the line(s) to change is:
netbeans_jdkhome="/usr/lib/jvm/java-8-oracle"
Comment out the old value and insert the new value.
As a further useful solution for those of you on Windows 7 and above - if you use
cd "C:\Program Files\Java"
mklink /D jdk8 jdk1.8.0_25
you get a symbolic link folder that can be adjusted whenever a new JDK comes out.
All you need to do then is set your
netbeans_jdkhome="C:\Program Files\Java\jdk8"
(in both locations for NetBeans 8) and you never have to edit the configuration again. Just tweak the symlink each time your JDK is updated.
I had this message too because today I decided to relocate my different JDK in the same directory. I have decided to uninstall all through the program manager of Windows. After that, of course I had the message below.
"Cannot locate java installation in specified jdkhome C:\Program Files (x86)\Java\jdk1.7.0_60. Do you want to try to use the default version?"
A new install of the JDK does not resolve the problem. OK, you can configure that in menu Tools → Java platforms, but in my case I had to fix my netbeans.conf file.
I had the line below:
netbeans_jdkhome="C:\Program Files\Java\jdk1.7.0_60"
And I replaced it by:
netbeans_jdkhome="C:\devtools\Java\jdk1.8.0_25"
It does not exactly answer your question, but to get around the problem,
you can either create a .cmd file with following content:
start netbeans --jdkhome c:\path\to\jdk
or in the shortcut of Netbeans set the above option.
Where you already have a project in NetBeans and you wish to change the compiler (e.g. from 1.7 to 1.) then you would need to also change the Java source compiler for that project.
Right-click on the project and choose Properties as outlined below:
Then check that the project has the necessary source circled below:
Then check that the Java compiler is correct for the project:
All the other answers have described how to explicitly specify the location of the Java platform, which is fine if you really want to use a specific version of Java. However, if you just want to use the most up-to-date version of the JDK, and you have that installed in a "normal" place for your operating system, then the best solution is to not specify a JDK location. Instead, let the NetBeans launcher search for the JDK every time you start it up.
To do this, do not specify jdkhome on the command line, and comment out the line setting netbeans_jdkhome variable in any netbeans.conf files. (See other answers for where to look for these files.)
If you do this, when you install a new version of Java, your NetBeans installation will automagically use it. In most cases, that's probably exactly what you want.
In Windows, open cmd.
Go to the directory where your NetBeans file downloaded.
Then run the below command. The JDK path may be different from the path I mentioned.
netbeans-8.2-windows.exe --javahome "C:\Program Files\Java\jdk-9.0.1"

Categories

Resources