I am using windows and configured environment variables for Java 11.
On the terminal, java version is 11 as expected and I am to compile and run Java class files via the terminal.
On Intellij (Community Version 2018.3.5), used to have version 8 which worked fine. I am not able to get it to work since changing to version 11 (tested with brand new projects too).
Under project Structure, file path is set to C:\Program Files\Java\jdk-11 as expected.
Under Project settings/ module, version set to 1.11 JDK. Unable to change language level to 11. Max level possible is 9.
For Default Project settings, unable to select any options for target bytecode version.
When I try to run the main method, which has nothing but a print statement, I get following error message:
Error:Cannot run program "D:\Program Files\JetBrains\IntelliJ IDEA
Community Edition 2017.3.3\jre64\bin\java" (in directory
"C:\Users\username.IdeaIC2017.3\system\compile-server"):
CreateProcess error=2, The system cannot find the file specified
Why is it looking at some weird space when my jdk path has been specified at C:\Program Files\Java\jdk-11 already?
Please advice what I am missing. Added some screen shots for reference.
UPDATE: My version is Community Version 2017.3.5. Refer to my comment below.
2018.3.4 works fine for jdk > 1.8
The problem you are having is because of the settings that are being used
Error:Cannot run program "D:\Program Files\JetBrains\IntelliJ IDEA
Community Edition 2017.3.3\jre64\bin\java" (in directory
"C:\Users\username.IdeaIC2017.3\system\compile-server"): CreateProcess
error=2, The system cannot find the file specified
Reinstalling and not reusing the same settings from 2017 should work fine.
Related
I've just istalled JDK8 on PC Windows 11 Home
Now im trying to run simple default program from NetBeans14
In environmental variables:
PATH : C:\Program Files\Java\jdk1.8.0_202\bin
CLASSPATH : C:\Program Files\Java\jdk1.8.0_202\bin
Project build on hard disk
C:\Projects\Hello\src\main\java\pack\hello
on cmd going tn cd C:\Projects\Hello\src\main\java\pack\hello
javac compiles .java file on .class file
command "java Hello" output: Error: Could not find or load main class Hello
Hello.class is there.
checking commands, all works:
java
javac
javac -version
Please to support, or send some similar problems posts.
All web answers are speaking about setting PATH and CLASSPATH, where in my case it already took place.
Thanks in Advance
I tried to follow your steps. I downloaded and installed the newest JDK 8 on Windows 11, and NetBeans 14.
Then I looked through the Environment Variables, and the only mention of Java was in the system Path variable:
You see, I have no CLASSPATH variable, nor haven't I manually set anything. Everything was installed automatically. I have no explicit path to C:\Program Files\Java\jdk1.8.0_... in my Path variable.
And I created a simple app in NetBeans. It runs from NetBeans successfully. Just do "Run Project" (F6) in the NetBeans interface.
If you need to run it from the command line for some reason, this question may help.
If you need to run it on another computer, I would advise you not to do it with cmd. Compile it into jar, then wrap it into exe (in case of Windows) using launch4J.
I'm trying to write a Java program in Intellij on Ubuntu 18.04. There is nothing wrong with the code, I can run it on my Windows machine at home.
When I'm trying to build the program i get the following error message:
Error:Cannot run program "/usr/bin/jdk1.8.0_202/bin/java" (in
directory "/home/oskar/.IdeaIC2019.1/system/compile-server"): error=2,
No such file or directory
First of check that /usr/bin/jdk1.8.0_202/bin/java is present - as in check that you have the Java SDK.
If you have it, Then you need to specify the SDK for your projectin iteliJ. To do this goto Project setting and select your SDK with the drop down, as shown below
Goto File -> Settings -> Project and you will see the bellow menu.
If you don't have the Java SDK there, go ahead and install the Java JDK download from https://www.oracle.com/technetwork/java/javase/downloads/index.html After installing the SDK, navigated to the Project Settings again and select the new JDK configuration from the installation location.
Then you can build the project and it should work all fine!
I'm trying to build a JavaFX application in e(fx)clipse using the build.fxbuild file. Unfortunately ant complains it can't find tools.jar. But tools.jar was removed starting from Java 9 (I'm actually using Java 10), so I can't add it to the ant classpath in Preferences > Ant > Runtime > Classpath. The actual error message on the console is this:
BUILD FAILED
<project_directory>\build\build.xml:59: 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 "C:\Program Files\Java\jre-10.0.1"
My JAVA_HOME environment variable is also set to point to JDK 10, it's included in PATH as well, so I also don't understand the last line. What can I do in this situation?
TL;DR - update your Eclipse / e(fx)clipse installation.
According1 to this blog posting e(fx)clipse 3.0.0 supports Java 9. (Apparently a lot of changes were required to get rid of dependencies on Oracle implementation classes.)
The Eclipse project page for e(fx)clipse 3.0.0 says that:
it was released in June 2017
it is part of the Oxygen release(s)
There is no specific mention of releases supporting Java 10 or later (yet), but another blog post talks about how e(fx)clipse will have to cope with JavaFX11 being unbundled from the standard Java SE distributions.
1 - I am not in a position to validate this information ...
Are you using an older version of eclipse or is your JAVA_HOME incorrect?
First, download and use java 9 or 10 JDK.
Set your environment variable correctly (don't use JRE location),
Update your path to include the bin folder in your JDK folder
Make sure you have a recent version of eclipse
I just updated to IntelliJ IDEA 16 which comes with Java JDK 1.8. Fyi, I had downloaded Java JDK 1.8 a long time ago.
I tried to run my plugin that I am developing, and I cannot even do that, I get the following error message (slightly condensed)
"C:\Program Files\Java\jdk1.7.0_45\bin\java" -Xmx512m -Xms256m -XX:MaxPermSize=250m -ea "-Xbootclasspath/a:C:/Program Files (x86)/JetBrains/IntelliJ IDEA Community Edition 144.3143.6\lib\boot.jar" -Didea.config.path=C:\Users\Christopher.IdeaIC14\system\plugins-sandbox\config - ... -Dfile.encoding=windows-1252 -classpath "C:\Program Files\Java\jdk1.7.0_45\lib\tools.jar; ... ;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 144.3143.6\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.intellij.idea.Main
Unsupported Java Version: Cannot start under Java 1.7.0_45-b18: Java 1.8 or later is required.
So, I clearly know what the problem is; however, I cannot seem to figure out where the location to fix this is.
I have tried a lot of things so far; most involve using the search box in Settings and switching whatever I could to version 1.8. Also, I had updated my Environment Variable for Java from 1.6 to 1.8
With all of these changes, nothing is working! So how do I go about fixing this seemingly simple issue?
Set IDEA_JDK (or IDEA_JDK_64) environment variable.
Check Selecting the JDK version the IDE will run under
TL;DR --> Set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_51
Java 8 is required to run IntelliJ IDEA starting from version 16 on all the supported platforms.
The actual JDK version used by the IDE can be verified in Help | About dialog (open any project to access the menu).
idea64.exe uses this JDK search in the following sequence:
IDEA_JDK_64 environment variable
..\jre64 directory
system Registry
JDK_HOME environment variable
JAVA_HOME environment variable
Under Arch Linux you can simply set java 8 as default (you must have it installed):
$ sudo archlinux-java set java-8-openjdk
In case anyone arrives here and hasn't had any luck with the other solutions, try this. I'm using PhpStorm under OSX, but the steps are probably applicable to JetBrains' other IDEs too:
Navigate to your IDE's config folder (see this article to learn how to find this folder's location).
Open the idea.propeties file.
If a JVMVersion attribute exists, delete that entire entry. If it doesn't exist, then this probably won't be of much help!
Save the file.
Launch your IDE.
Just set JAVA_HOME system variable to your JDK 8:
Run in cmd
setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0_111"
don't foget to change to your java path
In my case, Ubuntu 14 (32-bit), I opened the file:
/home/<user>/Programs/PhpStorm/bin/phpstorm.sh
and after
if [ "$JDK" = "" ] && [ "$OS_TYPE" = "Linux" ] && ........... fi
I added:
if [ "$JDK" = "" ]; then
JDK="/usr/lib/jvm/java-8-oracle"
fi
And then it works!
Double check that your JAVA_HOME points to the correct 1.8 Installation and make sure that in the PATH env there is no reference to "C:\Program Files\Java\jdk1.7.0_45\bin".
Try to print your JAVA_HOME/PATH from the Console and see what the output is. If your changes are not reflected logout and then login again.
IntelliJ 16 REQUIRES Java 8 to run, it won't run under Java 7. It's compiled to Java 8 classes so it can't ever be run on an older JVM.
This is well and clearly mentioned in the documentation.
So if you have your system JVM be an older one, it will fail to start unless you coerce it into using a non-default JVM.
Possibly you have some java related executables left over in your Windows/System32 directory, where some older Java installers would drop them. Delete these by hand from the file system and see what happens.
Just in case this page needs one more recommendation, I fixed the problem in my case by going to the IDE's config folder (as #Nate puts it, see here for how to locate it), and deleting the idea.jdk file (which held a reference to a 1.6 VM).
Apart from setting the correct Java version for the global, per project and per module SDK, for the Java Compiler, and for the language level, you also must set the Target bytecode version both for the project and (if you use maven) for each maven module.
Often the project bytecode version is correct but the module bytecode version is lower, i.e. 1.5.
The per-module bytecode version is not displayed when opening the default preferences via File > Other Settings > Default Settings. You must edit the current preferences either via a shortcut (i.e. ⌘+,) or from the main menu as shown below (for mac):
I had the same problem. All paths pointing to java jdk 8, but still throwing the error. I was able to run Android Studio by running the "studio64.exe" instead "studio.exe" in the bin folder
I'm trying to install Java to use Eclipse (I followed all instructions to install Java and Eclipse) but my Eclipse is not starting due to some bad configuration I guess. I can't figure out why it's not working for me.
Eclipse Installation:
Extracted Eclipse at C:\eclipse
Created a shortcut to my desktop having target C:\eclipse\eclipse.exe
When I try to run Eclipse with this shortcut, I see following Eclipse splash screen for a second and it disappears. Eclipse does not start at all.
JAVA Installation:
Installed JDK at C:\Program Files\Java\jdk1.7.0_10
Installed JRE at C:\Program Files\Java\jre7
Environment Variables Configuration:
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_10
PATH = C:\Program Files\Java\jdk1.7.0_10\bin;
I tested my Java installation using the console and figured out this issue but I don't know how to fix it, and I guess this is causing Eclipse not to start.
Problem:
Go to Eclipse folder, locate eclipse.ini file, add following entry (before -vmargs if present):
-vm
C:\Program Files\Java\jdk1.7.0_10\bin\javaw.exe
Save file and execute eclipse.exe.
please try to execute java from
C:\Program Files\Java\jdk1.7.0_10\bin
i.e from the location where java is installed.
If it is successful, it means that the error lies somewhere in the classpath.
Also, this guy seems to have had the same problem as yours, check it out
Check that downloaded eclipse/JDK/JRE is compatible with your processor/OS architecture that is are they 32bit or 64bit?
Not able to run Appium {“message”:”A new session could not be created. (Original error: ‘java -version’ failed
I used Jdk 1.8 and JRE 1.8, Classpath is also set properly but I observed that Java command gives Error to initialization of VM (java/lang/NoClassDefFoundError: java/lang/Object)
Solution:
Uninstalled JRE and JDK completely
Installed JRE 1.8 then
Installed JDK 1.8
Set Classpath
check Java command works or not and its working
also able to execute the Appium program thru Eclipse Kepler Service Release 2 with JDK1.8 support
I had the same error in my case was when I needed to update jdk 7 to jdk 8, and my bad was just I installed jdk8 and I never installed jre8, only that, the error was solved immediately when I installed jre8.
Try placing the desired java directory in PATH before not needed java directories in your PATH.
I had the same issue on Windows 7 and I had to install both JDK and JRE and it's a success.
I faced the same problem,Eclipse splash screen for a second and it disappears.Then i noticed due to auto update of java there are two java version installed in my system. when i uninstalled one eclipse started working.
Thanks you..
I've observed this with STS and Eclipse and running java from CMD too on Windows 7/8/10 and following was my simple solution:
Actually, when I installed JDK 8 and STS/Eclipse it created one directory i.e. C:\ProgramData\Oracle\Java\javapath with the following files:
C:\ProgramData\Oracle\Java\javapath\java.exe
C:\ProgramData\Oracle\Java\javapath\javaw.exe
C:\ProgramData\Oracle\Java\javapath\javaws.exe
Along with that, it appended Path Environment variable of System with this location C:\ProgramData\Oracle\Java\javapath
I've just removed above entry from Path Environment variable of System and added the location of the actual JDK instead i.e. C:\Program Files\Java\jdk1.8.0_131\bin
Now that is not necessary to add that -vm option in eclipse.ini or
SpringToolSuite4.ini either.
I just spent about 1 hour to figure out possible solution for the same error.
So what I did under MS WIndows 7 is following
Uninstall all Java packages of all versions.
Download last packages Java SE or JRE for your 32 or 64 Windows and install it.
First install JRE and second is Java SE.
Open text editor and paste this code.
public class Hello {
public static void main(String[] args) {
System.out.println("test");
}
}
Save it like Hello.java
Go to Console and compile it like
javac Hello.java
Execute the code like
java Hello
Should be no error.
sometime you missed some file like I missed my one file rt.java
so better to check yours .........
C:\Program Files\Java\jdk1.8.0_112\jre\lib
0
I just spent about 1 hour to figure out possible solution for the
same error.
So what I did under MS WIndows 7 is following
Uninstall all Java packages of all versions.
Download last packages Java SE or JRE for your 32 or 64 Windows and
install it.
First install JRE and second is Java SE.
List item
Below error is thrown when there are multiple versions of jdk on your machine:
error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
so for this Just use below:
set PATH="JDK bin path" in cmd
I had a same issuse, my file location was in D-drive, and then i shifted to the c-Drive and it works.