Why cant i run Jar file in Windows? - java

I am trying to run a javaFx jar in windows cmd with java -jar filename.jar but i get this error:
Error: JavaFX runtime components are missing, and are required to run this application.
In intellij works the programm fine but i cant run it in Windows. Any Ideas?
This is my Java Version
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)

Related

how to change the java path that is being referenced

I had had previously installed java on my mac. I just downloaded a new version of java from their website. when i run java -version in my terminal I get this
omars-mbp:local omarjandali$ java -version
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
omars-mbp:local omarjandali$
I want delete the version above and have to point it to the new java version that I just downloaded which is
version 8: (build 1.8.0_211-b12)
how can i redirect it accordingly

GlassFish5 w/JDK8 under MacOS JDK11 install

Need to run GlassFish5 on MacOS. Current version installed are JDK11.02 and JDK1.8.0_144.
>echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
>which java
/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/bin/java
>java -version
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
I have appended the last line in file glassfish5/bin/asenv.bat with
AS_JAVA=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
And I still get a NPE Exception when starting up GlassFish:
>asadmin start-domain
Exception in thread "main" java.lang.NullPointerException
What am I missing?
Or is running GlassFish w/JDK 8 (u144) on MacOS with a JDK11 not possible?
Instead of setting AS_JAVA variable in asenv.bat, you need to set AS_JAVA in glassfish5/config/asenv.conf.
AS_JAVA=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

elasticsearch won't start because it can't find java 8

I'm trying to run an instance of elasticsearch version 1.8 on an ubuntu machine.
When i elasticsearch I get:
es#ubuntu-mwa-flask:/root/elasticsearch-5.4.0$ ./bin/elasticsearch
Error: Could not find or load main class org.elasticsearch.tools.JavaVersionChecker
Elasticsearch requires at least Java 8 but your Java version from /usr/bin/java does not meet this requirement
I've checked which java version I have:
es#ubuntu-mwa-flask:/root/elasticsearch-5.4.0$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
What am I doing wrong? I've installed elasticsearch on afew machines before, why doesn't this one work?
edit1: since someone asked:
es#ubuntu-mwa-flask:/root/elasticsearch-5.4.0$ /usr/bin/java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
mixed mode)
edit2:
es#ubuntu-mwa-flask:/root/elasticsearch-5.4.0$ javac -version
javac 1.8.0_131
Probably you don't have right permissions. Try to set them to 774 and check again:
sudo chmod 774 -R elasticsearch-6.3.2/

Why does my uberjar not work on Windows 7?

I created a new project using Clojure by doing this on a Mac:
lein new app clojure-noob
Created my uberjar using
lein uberjar
Sure enough, I can run this uberjar via:
java -jar target/uberjar/clojure-noob-0.1.0-SNAPSHOT-standalone.jar
And I get:
Hello, World!
Now I take this file to Windows 7 and give the same command:
java -jar clojure-noob-0.1.0-SNAPSHOT-standalone.jar
I seem to get an infinite wait. Why can’t I get to runt his .jar file on Windows?
The java version on Mac is:
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
The java version on Windows 7 is:
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) Client VM (build 25.66-b18, mixed mode)
lein version gives the following: Leiningen 2.5.3 on Java 1.8.0_51 Java HotSpot(TM) 64-Bit Server VM
The answer is that I was trying to run the .jar from shared folders on a Windows 7 VM from VirtualBox running on a Mac. This IO is very slow.
When I just copy that file to, say, Desktop and run from there - the access is quiet fast. Thanks SubOptimal for helping me figure this out.

How to install Java 8 on machine with other Java versions

I installed Java 8 (jdk-8u60-windows-x64.exe) on machine with several other versions.
After installation I see the following message
d:\Userprofiles\user>java -version
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.8', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
I can change JAVA_HOME to the new location but this does not fix the above message.
When I edit the registry and change 1.8 in serveral registry keys to 1.7 I have a working configuration again. But this is still 1.7.
Changing JAVA_HOME does not seem to have any effect. When I change it to my new installed JDK
d:\Userprofiles\user>java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
d:\Userprofiles\user>echo %JAVA_HOME%
D:\Program Files\Java\jdk1.8.0_60
What do I need to do to have 1.8 working on my machine? JAVA_HOME seems obsolete now, should I change the registry? What should I do to change registry so that picks up the 1.8 version?
It's not enough just to introduce the value for %JAVA_HOME% (actually, Java doesn't care if there is or there isn't such environment variable).
What you have to do is to append %JAVA_HOME%/bin directory to the Path environment variable, so that you get the java.exe that matches the %JAVA_HOME% version, without having to write the full path to the java.exe executable that you want to trigger.
So, either do this:
set a value for the %JAVA_HOME% environment variable
append %JAVA_HOME%/bin to the Path environment variable
or just
append <the-java-home-directory>/bin to the Path variable.
Personally, I would prefer to maintain a value for JAVA_HOME, as it is needed by tools like Maven, Hadoop, etc.
You can have as many JDK's installed as you want, and you don't even need them in the PATH, or to set JAVA_HOME.
The first one found in the PATH will be the default one. Remember to only install the JDK, not the JRE that always comes with the JDK, i.e. unselect the 3rd option when installing.
I have 9 JDK's installed, and I can run all of them without changing anything. All you have to do is qualify the executable:
C:\>prog\java32\jdk1.4.2_19\bin\java.exe -version
java version "1.4.2_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)
Java HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)
C:\>prog\java32\jdk1.5.0_22\bin\java.exe -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode)
C:\>prog\java32\jdk1.6.0_45\bin\java.exe -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)
C:\>prog\java32\jdk1.7.0_79\bin\java.exe -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) Client VM (build 24.79-b02, mixed mode, sharing)
C:\>prog\java32\jdk1.8.0_51\bin\java.exe -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode, sharing)
C:\>prog\java64\jdk1.5.0_22\bin\java.exe -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)
C:\>prog\java64\jdk1.6.0_45\bin\java.exe -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
C:\>prog\java64\jdk1.7.0_79\bin\java.exe -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
C:\>prog\java64\jdk1.8.0_51\bin\java.exe -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
That was the output in a single Command Prompt, without ever setting the PATH.

Categories