Related
I'm trying to make a cross-platform JavaFX application, and it works fine on Windows and OSX machines, but not on Linux.
When I try to run it on a Linux machine using java -jar app.jar, this is what I get:
Error: Could not find or load main class app.Main
But the class app.Main is in the .jar, as shown by 'jar tf app.jar':
...
app/Main.class
...
I tried specifying the main class using java -cp app.jar app.Main but I got the same error message.
The .jar was built in Intellij IDEA, using basic JavaFX configuration.
Any help?
So, turns out the problem was that the JRE on the Linux machine was OpenJDK, which does not come with JavaFX, as noted by James_D and jewelsea
After installing the oracle JRE 8, it worked fine
Sorry for the necro post, but I had to take a few extra steps. I had JRE 8 installed, but I still had to point java_home to it.
I'm using a MAC.
The JDK locations are here:
/Library/Java/JavaVirtualMachines (verify this)
The default JDK for my machine was temurin-17.jdk
I had to change it to jdk1.8.0_301.jdk
Steps:
Open a terminal
Type:
vim ~/.bash_profile
I pasted this onto the file:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home
Save and exit vim:
https://phoenixnap.com/kb/how-to-vim-save-quit-exit
In the terminal, type:
source ~/.bash_profile
Restart your terminal
In the terminal, type:
java -version
Make sure it's pointing to the right version
Now navigate back to where the .jar is located.
In the terminal, type:
java -jar myapp.jar
Hope this helps.
I have researched this and none of the solutions that I have seen have fixed my error.
What is happening is I tried to install Java EE version got the above error and then found out that I must install Java SE first. So I installed Java SE and set the JAVA_HOME variable to C:\Program Files\Java\jdk1.8.0 which is where I installed my JDK. I also put C:\Program Files\Java\jdk1.8.0\bin in my PATH variable. Still not working. I also tried the JAVA_HOME variable with C:\Program Files\Java\jdk1.8.0\bin and that didn't work. I also tried installing without the PATH variable being updated to where I put my JDK.
I'm really getting confused as to why this is happening. I've had Java before and I don't recall having this much trouble installing it.
PS I don't install from the command line I just click the download icon in Firefox and then click the download.
Try running the installer at your commandline and pass the path of the JRE instead of the JDK.
For Example:
java_ee_sdk7-windows.exe -j "C:\Program Files\Java\jre8"
I had the exact same problem and even downloading the version without JDK didn't help!
I simply installed it from the terminal with passing the JRE For Example:
java_ee_sdk7-windows.exe -j "C:\Program Files\Java\jre7"
and it worked like a charm!
I had the same problem but an additional step was required in order to install using the command line. In the command window (on my Windows 10 laptop) I had to use:
cmd /d
to tell the cmd window to ignore registry AutoRun commands before the java installation executable would run. After using cmd /d, and changing to the directory where the .exe file was at, the following worked:
java_ee_sdk-6u4-jdk7-windows-x64.exe -j "%JAVA_HOME%"
Where JAVA_HOME is a system environment variable pointing to an existing JDK installation (C:\Program Files\Java\jdk1.8.0_65).
Uninstall everything, all of it.
Then go to your Program Files folder (and (x86) folder if on a 64bit Windows) and physically remove any Java folders.
Reinstall Java SE and then the EE packages. Sometimes Windows appears to get a bit confused and you need to help it figure out what to do.
If you want to uninstall, go to the glassfish folder and open the command prompt, then type:
uninstall.exe -j <The path to your JRE>
These points may be helpful.
java EE SDK7 contains glassfish v4.0 and it compatible with JDK6 and JDK7.
java EE SDK8 contains glassfish v5.0, it compatible with only JDK7 and JDK8, not JDK 9 or beyond.
So environment variable JAVA_HOME has to point to the root directory of one of the mentioned JDK. and %JAVA_HOME%\bin should be added to environment variable path
Despite having followed all of the above, setup of java EE SDK7 gets error:
could not find the required version of the Java(TM;
as Bakudan and laf8 said,
open cmd using run, with /d /a options as followed.
cmd /d /a
and next run SDK7-setup with -j option like this command
sdk7.exe -j "%JAVA_HOME%"
note that %JAVA_HOME% enclosed BY ""
This was happening to me when I tried to run the Java EE installer. What I did, was to download from Oracle a Java EE version which didn't include the JDK, because it was already installed in my system. Problem solved!
Open regedit.
goto :HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\
set CurrentVersion to desired JDK version.
Check JavaHome and RuntimeLib path's for selected jdk version folder
Check JavaHome and RuntimeLib path's for selected jdk version folder
example: "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.7".
example:
JavaHome=C:\Program Files (x86)\Java\jdk1.7.0_79
RuntimeLib=C:\Program Files (x86)\Java\jdk1.7.0_79\jre\bin\server\jvm.dll
Source: http://tech-read.com/2009/05/19/how-to-solve-error-could-not-find-java-runtime-2-environment-while-opening-an-ide/
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.
I have set Path and ClassPath environment variables. But still I am unable to compile my HelloWorld.java program from command prompt. Please help me compile and run java program from command prompt
CLASSPATH C:\Program Files\Java\jre6\lib
Path C:\Program Files\Java\jre6\bin\
You need to add JDK's directory to your path variable (not your JRE's path as you are actually doing it). JDK is usually in:
C:\Program Files\Java\jdk1.6.0_xx\bin\
Where xx stands for update number you have installed. Then just compile HelloWorld by using:
C:\Your\dir\where\HelloWorld\Is\>javac HelloWorld.java
In case you don't have JDK installed and you have only JRE installed, you won't be able to compile anything. You will need to download and install JDK properly to do Java Development in general (including compiling stuff).
You need a JDK to compile classes rather than a JRE. The JRE is used for running Java applications (the JDK can also do this, but you cannot distribute the JDK).
When you have installed a JDK, ensure that the JDKs bin directory is on your path. You can then compile your Java classes using the javac.exe command.
PATH must be like
C:\Program Files\Java\jdk1.6.0\bin (This is on my system)
That is must point to JDK's bin not the jre's bin.Hope this helps.
You should also have your current directory in the CLASSPATH.
set CLASSPATH=.;C:\Program Files\Java\jre6\lib;
You could try writing cd C:\examples\ch01\ATM then press enter and that will change your directory. This allows you to write for example java ATMCaseStudy, then press enter. This should work if you placed your directory in C with your JDK in the same place.
Eclipse is unable to open, have used eclipse before and has open before without a problem. Now I keep getting the following error message:
A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations:
Have gotten eclipse to open and work on projects before and won't open.
Here is a screen shot of what I keep getting:
You can explicitly tell Eclipse where to find it. Open eclipse.ini and add the following lines to the top of the file:
-vm
/absolute/path/to/jre6/bin
Update: I just nailed down the root cause on my own Windows machine. The GlassFish installer complained with exactly the same error message and after digging in GlassFish forums, the cause was clear: a corrupt JRE install on a Windows machine. My JRE came along with the JDK and the Java 6 JDK installer didn't install the JRE properly somehow. A DLL file was missing in JDK's JRE installation. After I reinstalled the standalone JRE from http://java.com, overwriting the old one, the GlassFish installer continued and also Eclipse was able to start flawlessly without those two lines in eclipse.ini.
I got this problem because i uninstalled the jdk version 13 and reinstall the jdk version 8
Even though i have updated the path variables eclipse still pick the old configuration.
You need to edit the eclipse.ini file which is in your folder where eclipse.exe is placed.
Just update this file with the latest path so eclipse can pick it up
It usually is because:
you indicated the wrong jvm path in your -vm argument: see this SO question for an concrete example.
the eclipse.ini got corrupted somehow (if it hasn't been modified, this isn't it, but if setting a jvm path doesn't work, ... I would replace the eclipse.ini by one coming from a fresh installation just to be sure)
the java which eclipse search by default is no longer accessible (because the $PATH is no longer up-to-date)
More details on the wiki page "Finding a VM, Using JNI Invocation or Executing Java"
No -vm specified
When no -vm is specified, the launcher looks for a virtual machine first in a jre directory in the root of eclipse and then on the search path.
If java is found in either location, then we look for a jvm shared library (jvm.dll on window, libjvm.so on *nix platforms) relative to that java executable.
If a jvm shared library is found we load it and use the JNI invocation api to start the vm.
If no jvm shared library is found, we exec the java launcher to start the vm in a new process.
As mentioned in "FAQ How do I run Eclipse?":
Eclipse DOES NOT consult the JAVA_HOME environment variable.
So I would check your $PATH, starting by n new shell sesion (whatever your OS is), typing 'java -version' to see if it still returns anything.
Copy javaw.exe from C:\Program Files\Java\jre1.8(or)1.6(or)1.7\bin
and paste it inside Eclipse folder
where eclipse.exe is there. That's all.
Here is how I fixed mine:
find the location where your jre is installed. in my case, it was located at C:\Program Files\Java\jdk1.7.0_10
copy the jre folder and paste it where your eclipse files are located (where eclipse.exe is located).
when you download eclipse, you get a .zip package containing eclipse.exe and all the other files needed to run eclipse but it is missing the jre files. so all you need to do is to find where jre folder is located on your hard drive and add it to the rest of the eclipse package.
I had the same problem and the issue was that I had a 32 bit version of Eclipse running on my 64 bit machine and it wanted the 32 bit version of JRE.
I changed Program Files to Program Files (x86) in the eclipse.ini file like so:
-VM
C:Program Files (x86)\Java\jre6\bin
and that solved the problem.
You may want to just install the 64 bit Eclipse, but this will take care of the error.
Did you install Java via the java.com web browser auto install? If so, then that's your problem! You need to to the "manual" install: http://www.java.com/en/download/manual.jsp
It's just a matter of having the correct match of 32-bit Eclipse/32-bit Java or 64-bit Eclipse/64-bit Java. Many 64-bit Windows have 32-bit browsers and the latter is the version of Java that the auto-installer will provide - not what the 64-bit Eclipse wants.
Make sure the install path of JDK is in your Path variable in Windows.
adding -vm C:/Program Files/Java/jdk1.6.0_29/bin/javaw.exe to the .ini file helped me.
Is so simple,only add your java path for example:
C:\Program Files\Java\jdk1.8.0_121\bin
in PATH system variable
I have faced the similar issue earlier with Eclipse and STS IDE'S
Please check weather JDK/JRE is available or not in your machine. If not please install JDK and setup the environment variables.
Even after step 1, if you are still facing the issue then it's time to set the vm argument in eclipse.ini or sts.ini in the following way.
-vm
C:Program Files (x86)\Java\jre8\bin
I also had same problem when developing android applications using eclipse IDE.
I solved it by removing all the java installations (I had java 6 and 7 both) and re-install only jdk 7.
I got this fixed by doing the below steps,
1)
The eclipse finds the JAVA executables from 'C:\ProgramData\Oracle\Java\javapath'
The folder structure will contain shortcuts to the below executables,
i. java.exe
ii. javaw.exe
iii. javaws.exe
For me the executable paths were pointing to my (ProgramFiles(x84)) folder location
I corrected it to Program Files path(64 bit) and the issue got resolved
Please find the screenshot for the same.
Just to add on top of other answers:
Windows Users: You can give the PATH to JRE in eclipse.ini separated by '/' or '\'. It doesn't matter. Eclipse will pick it anyway. For example, in my windows system, either of the paths is fine (after -vm of course):
C:/Program Files/Java/jre1.8.0_181/bin
or C:\Program Files\Java\jre1.8.0_181\bin
Change the vm value in eclipse.ini file with the correct path to your JDK something like this,
-vm /Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk/Contents/Home/bin
Path to eclipse.ini looks to me something like this,
/Users/tomcat/eclipse/jee-2018-09/Eclipse.app/Contents/Eclipse
This sometimes happen if you remove Java from your path variables.
To set the PATH variable again, add the full path of the jdk\bin directory to the PATH variable. Typically, the full path is:
C:\Program Files\Java\jdk-11\bin
To set the PATH variable on Microsoft Windows:
Select Control Panel and then System.
Click Advanced and then Environment Variables.
Add the location of the bin folder of the JDK installation to the
PATH variable in system variables.
I had this problem too on a win7 machine.
I wanted to update the jre with a jdk. So i deleted the jre folder and downloaded and unzipped the new jdk.
The issue was i manually deleted the jre folder, when instead i should've uninstalled it. This leaves a bunch of registry entries that still point to the old jre. Somehow eclipse still wants to use the old jre.
I couldn't uninstall the old java vm, i kept getting this error:
Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor
So i had to use this MS utility to fix the uninstall:
http://support.microsoft.com/kb/2438651/
Then i had to install again the vm. I installed to the same location the original one was at, to avoid losing another hour! After that eclipse started correctly.
Julio
I just had this problem and fixed it this way. I noticed the error message has jre in it not jre6 or jre7, so i copied jre6 from program files to eclipse folder then renamed it from jre6 to jre, then it worked :p
Newb move on my part, but I had installed just the JRE instead of JDK. Installed JDK and my problem went immediately away.
I had this problem and it was due to my windows machine playing up. I went into control panel -> system -> advanced - environment variables.
I edited the PATH variable (which was already correctly set up), changed NOTHING, clicked OK to come back out of the screens.
Then eclipse worked. No idea why, except because windows. Hopefully this may help someone.
I had this issue; I fixed it by going to
Computer-->Properties-->Advanced Settings-->Environmental Variables
In the System Variables find the variable named PATH.
-->Select Edit
-->At the very end of the Path Variable, put a ";" then add your path of your JDK and put \bin\ at the end
Should be fixed.
Example:
System Variable-
C:\Program Files (x86)\Common Files.......HP\LeanFT\bin
JDK path-
C:\Programs Files\Java\jre1.8.0_121
Final Path -
C:\Program Files (x86)\Common Files.......HP\LeanFT\bin;C:\Programs Files\Java\jre1.8.0_121\bin\
Sources:
https://www.java.com/en/download/help/path.xml
Its simple.
JDK bin directory or JRE bin directory should be in path variable
Example :
Java Installed directory:
Assume your java installed in 'C:\Program Files\java\Jdk1.8.0_144' directory
Now you can find bin directory in 'C:\Program Files\java\Jdk1.8.0_144\bin'
Navigate to user's environment variable
Control Panel --> User Accounts --> User Accounts --> Change my environment variables
In popup click Path under User variables for section
Click Edit... button and another popup will appear
Click New button and enter C:\Program Files\java\Jdk1.8.0_144\bin
Click OK button and again OK button in Environment variables popup.
Now you can open your eclipse without error
I found a solution wherein the Eclipse.ini the location was the old version of Java, and after updating the new version of java the location of
-vm
C:\Program Files\Java\jre1.8.0_201\bin
was same so I had to change the directory to my new version of Java.
So solution is to just open the most updated Java version and copying its directory path and replacing it in the Eclipse.ini file.
Moderately future proof example for Linux-like systems. Assuming javac installed and on your path.
./eclipse -vm dirname $(readlink -f $(which javac))
This will find the directory where javac is installed, and pass as vm argument to eclipse.
If on Linux (ex: Ubuntu 18), try installing (or reinstalling in your case?) default-jre, as follows:
sudo apt update
sudo apt install default-jre
I had the same error when just trying to run the Eclipse installer (./eclipse-inst) on a fresh Eclipse download just now, and the installer wouldn't even run! Installing default-jre solved it!
Source:
https://linux4one.com/how-to-install-eclipse-ide-on-ubuntu-18-04/
In my case I had edited the eclipse.ini for a different purpose to include -vm parameter. That was causing the failure. I removed the -vm and following line where I had included \bin and that fixed the problem.
I got ERROR:
RESOLUTION :
in file eclipse.ini at below location :
make change as :
-vm
C:/Program Files/Java/jdk1.8.0_251/jre/bin/server/jvm.dll
Restart eclipse and error will be resolved
C:\Program Files\Java\jre1.8.0_221\bin
worked for me