JAR file I created runs only on computers with JDK installed - java

I recently created an application using the NetBeans IDE. I deployed it and created a jar file that runs perfectly on my computer and any computer that has the Java JDK installed, but when I try to run it on another computer that only has the JRE installed it says:
"Error: A JNI error has occurred, please check your installation and try again"
and then
"A Java Exception has occurred."

If you have JDK that you used to create jar with version1 and jre with version2 then you will encounter this kind of error.
For example:
If i used Java JDK 12 installed on my computer#1 to create jar.
At the same time, I had Java 8 (JRE) Installed on my friends computer.
So on my friend's computer it is not working because it has jre8..
I typed the follow commands to troubleshoot :
On computer#1 :
javac -version
// this gave me Java 12
On computer#2
java -version
// this gave me Java 8
In other words, my program is getting compiled with Java 12 (computer1)and I am trying to run with Java 8 on computer2.
To solve the problem, try running jar on same version of java used for development. Means match jdk and jre version.

Related

No Java Virtual Machine was found while installing eclipse

I have downloaded "eclipse-jee-juno-SR1-linux-gtk-x86_64.tar.gz" from www.eclipse.org for linux-64 bit OS.
When i tried to run the installer, by double clicking on it. It showed the error
"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:
/home/shubham14/Downloads/Softwares/eclipse-jee-juno-SR1-linux-gtk-v86_64/eclipse/jre/bin/java
java in your current path."
I dont understand why this error has occured since i have jdk 14 already installed and its path is also set.

Eclipse not recognizing JVM 1.8

Still trying to get Eclipse IDE to work and running into Incompatible JVM error. I followed the steps here: I installed Java 7 but Eclipse keep saying that 1.6 is not suitable for this product
But unfortunately to no effect. Running OSX 10.9.5 and uninstalled the out-of-the-box version of Mac. The new version of Java seems to show up in the System Preferences. Please see attached screen capture. I've even done some of the basics like restart my computer, etc. Maybe there are other modifications I need to make to other files. I'm comfortable with Terminal but new to Eclipse and Java.
I have had the same problem as noted above. I could not get Eclipse to install because of Java incompatibilities. The sequence I followed goes like this:
Upgraded to MAC OS Sierra
Downloaded the Eclipse installer but was prompted that I needed to instal a legacy Java.
Installed Java 1.6
Was unable to install Eclipse and was prompted that I needed Java 1.7 or greater. Downloaded and installed Java 1.8
Ran the terminal code 'java -version' // this will check your jre version. This showed returned Java 1.6 despite the fact that I had upgraded to 1.8. The Java version listed in the Java control panel said 1.8
Tried multiple downloads of eclipse and Java and multiple restarts always with the same result.
Visited the Oracle web page noted above:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html I could not find the above reference to 8u73 and 8u74 but I did find and option to download 1.8.0_12. I did this. It installed without difficulty, and then I was able to install Eclipse without difficulty.
This took hours of my time. I hope this proves useful.
OK, so I don't really know what the problem was, but I simply fixed it by navigating to here http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and installing 8u74 instead of 8u73 which is what I was prompted to do when I would go to "download latest version" in Java. So changing the versions is what did it in the end. Eclipse launched fine, now. Thanks for everyone's help!
edit: Apr 2018- Now is 8u161 and 8u162 (Just need one, I used 8u162 and it worked.)
JRE is a Run-Time Environment for running Java stuffs on your machine. What Eclipse needs is JDK as a Development Kit.
Install the latest JDK (and not JRE) from http://www.oracle.com/technetwork/pt/java/javase/downloads/jdk8-downloads-2133151.html and you should be good on Mac!
Open up terminal and check what java version is currently set in your path variable.
You can do that by typing in your terminal
java -version // this will check your jre version.
javac -version // this will check your compiler version
If this shows incorrect java version but you have installed java 1.8 then you have to set path variable to the newer version of java.
To do that do add the line:
export JAVA_HOME=/path/to/java/jdk1.x
to ~/.bash_profile (same as /Users/username/.bash_profile)
Then do this from the terminal to set the new variable
source ~/.bash_profile
Also what's your eclipse.ini set to ?
-Dosgi.requiredJavaVersion=1.7
EDIT:
Please open up terminal and type
find / -name "java" // This should find all folder named java on your file system.
Also how did you install java in the first place ?
Echoing the answer, above, a full install of the JDK (8u121 at this writing) from here - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html - did the trick. Updating via the Mac OS Control Panel did not update the profile variable. Installing via the full installer, did. Then Eclipse was happy.
Here are steps:
download 1.8 JDK from this site
install it
copy the jre folder & paste it in "C:\Program Files (x86)\EclipseNeon\"
rename the folder to "jre"
start the eclipse again
It should work.
For some weird reason "Java SE Development Kit 8u151" gives this trouble. Just install, "Java SE Development Kit 8u152" from the following link-
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
It should work then.

Setting required Java version for .jar file to run with?

I have a program that cannot run as long as Java 8 is installed on my system. Can I specify which version of java that should run that specific .jar file, so I don't have to uninstall it each time I'm going to run the program?
you could check the Java Version at the start of your main class and exit it if a version lower then 1.8 is installed.
take a look here Getting Java version at runtime

Can't find 1.7 JDK after installing it

I'm trying to update from Java JDK 1.6 to 1.7 and have downloaded the version 7 JDK for mac (I downloaded jdk-7u71-macosx-x64.dmg from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html)
However after running the installer, which executes, says its installing and copying the files, then indicates the installation was successful I can't find where they have installed to.
I can see the previous version of the jdk is installed at /System/Library/Java/JavaVirtualMachines/1.6.0.jdk.
But there's no sign of 1.7, nor using spotlight can I find any other .jdk or anything called 1.7.* anywhere on my machine, despite the JDK installer saying it was successful (I've tried running the installer a few times).
If the installer is saying it was installed why can't I find it? Is it supposed to have gone into /System/Library/Java/JavaVirtualMachines/ like the 1.6 one, if so why isn't it and how can I install it when the installer is saying it did so?
[OS X 10.9.5]
You installed the JDK yourself so it won't be in /System.
Try looking in /Library/Java/...
You'll need to add this new runtime to your path to get it to work on the command line.

How to run Jcalltracer

Hey guys I'm having trouble opening jcalltracer, an open source program on sourceforge that reverse engineers a Java program into sequence diagram. I got error when I was trying to add the following to JVM -
java -agentpath:C:\calltracer\jvmti\calltracer5.dll=traceFile-C:\calltracer\call.trace,filterFile-C:\calltracer\filters.txt,outputType-xml,usage-uncontrolled -Djava.library.path=C:\calltracer\jvmti -Dcalltracerlib=calltracer5
Error -
Error occured during initialisation of VM
Could not find agent library C:\calltracer\jvmti\calltracer5.dll in absolute path, with error: Can't load IA 32-bit .dll on a AMD 64-bit platform
I am using Windows 7 x64 and I'm very sure that I installed the x64 version after checking the java sdk I downloaded and doing a java -version check. Any clues?
Looks like the calltracer5.dll has been compiled to work on a 32bit platform. You will need to recompile for 64bit.

Categories