I am trying to run the jar file on linux created from windows using jdk7 .
I am using the following command to run the
java -jar jarfile.jar
its running the jar and throwing the exception as un recognised class format version. because linux is showing the java version as 1.4.2 while i have extracted the jdk1.7 in the root directory but it is still taking the java version as 1.4.2 . what i have to do to run the jar file created using jdk1.7 . I have extracted the java (jdk1.7) on linux in root directory.
You need to specify the JDK 1.7 on your path e.g.
$ PATH=/jdk17/bin:$PATH
Note how you specify not just the path to the 1.7 installation, but the bin path within that.
Typing
$ which java
after you've changed the PATH will confirm if this has worked.
Make sure jdk1.7 in front of jdk1.4.2 in system variable PATH. Do you have installed oracle in your Linux OS? I have encountered the same question in windows OS because I have installed oracle. If some software just like oracle is installed, maybe it will insert jdk1.4 in front of all other software paths in system variable PATH.
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.
Is it possible to get Java in zip format? I don't want to install it by getting .exe file.
Is there any zip version of Java 1.8 so that I can download it and extract it and start using it in my Windows machine (64-bit processor)?
You can extract the JDK folder from the Installation EXE.
Check this link for the steps. The post was for JDK 1.7 it will work for JDK 1.8 also
Do the following.
Steps
Download JDK from Oracle
Download and Install 7-zip from here
Open installition exe using 7-Zip
Extract the tools.zip
Extract the content of tools.zip to a folder (e.g. c:\jdk).
Open the extracted folder in cmd prompt.
Execute for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar" command
Set JAVA_HOME to the jdk (e.g c:\jdk) folder.
Add %JAVA_HOME%/bin to the PATH env variable.
Testing
Run the following command to check the installation, it will print the version of JDK.
c:> javac -version
javac 1.7.0_51
NOTE: Tested with JDK 1.7 and 1.8
Update 1
Edited the answer to add the steps in the answer itself instead of the link to a blog post.
Update 2
For 64-Bit please check unpack-jdk-x64.bat by grabantot
I was looking for a solution to this as well. I'm not sure why the OP wanted to do this. I'm just trying to get a newer version of java for new development while not interfering with an older Java install which a legacy application requires (I'd like to update the legacy app, but it's not an option, now)
I think the hack I am going to try is this:
Install 1.8
Take a copy of the install folder
Uninstall 1.8
Reinstall / Repair 1.7
restore the copy of 1.
I'm sure if I had a better understanding of what the install is doing, this would not be necessary.
I had a spare virtual machine hanging around (if not you could build one or maybe even download one) so I:
installed the Oracle JDK in the guest
copied the jdk folder from the guest to the host
added a JAVA_HOME environment variable.
The operating systems obviously have to be close (not sure how close, I used Windows Server 2008 64 bit guest on a Windows 10 64 bit host and it seemed to work).
Was a quick fix for me as I didn't want a full install and wanted to remove it afterwards.
If you do not have permission to unzip zip file then you cannot install java .
As java does not need installation for running . You just need to give path of java.exe where it is located .
In Windows it is located in C:\Program Files\Java\jdk1.8.0_05\bin
For a solution you can run installer on any machine that you have permission and just copy and paste the folder of java to anywhere in your system (Machine where you have administrative rights problem) . and just set the path as by opening command prompt as set path="C:\Program Files\Java\jdk1.8.0_05\bin"
java will be working as you want
The following worked for me (I had JDK 1.8 installed and needed the 32 bit version as well):
Verify the current version with java -version
Assuming a different version (minor or major is being installed), download the relevant JDK installable from Oracle and run it. In the
first dialog, specify a different folder than the default location
(might work with the default one as well), then select Next. It will
extract the files there in this folder, then it will asl for the
folder where the JRE is to be installed. Simply close the installer,
now you should have just the JDK in the specified folder.
Rerun java -version, it should give you the same version as earlier.
Worst case, if it shows the newer version, go to your system path (Right click My Computer (or This PC) -> Properties -> Advanced
system settings -> Advanced tab -> click on Environment variables
button) and remove the Oracle javapath entry (From the Path variable
in the bottom part of the window). The add the older java version's
bin folder to the path variable in the beginning.
for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"
Is this working for linux shell scripting , I got syntax error for the above.
I am trying to run the typesafe activator on Windows7 (32bit).I have JDK 1.8 installed. It keeps saying I don't have a valid JDK installation:
A Java JDK is not installed or can't be found.
Please go to
http://www.oracle.com/technetwork/java/javase/downloads/index.html
and download a valid Java JDK and install before running Activator.
If you think this message is in error, please check
your environment variables to see if "java.exe" and "javac.exe" are
available via JAVA_HOME or PATH.
I had a similar problem on Windows 7 64b. The problem solved by changing the installed directory from "C:\Program Program..." to a directory without space like "c:\java".
So the solution is: Installing Java to a path without spaces.
I hope it can help.
Put the Activator Directory (not the Java Directory) where it's path does not contain spaces! (ie C:\Program Files\ ... is NOT valid)
Also place the Java PATH before all other paths in your Environment Variables.
I am running currently on Java 1.7.0_17 64bit version and I want to launch an app using Java 32 bit version.
I updated PATH variable to point to (C:\Program Files (x86)\Java\jre7\bin) Java 32 bit version. Then did a java -version it still shows the 64bit version.
I gave up and tried to do a java -d32 -jar abc.jar and then it gives me an
java -d32
Error: This Java instance does not support a 32-bit JVM.
Please install the desired version.
Please let me know how can the system refresh the latest Java settings done in the PATH variable.
There is probably a java.exe in your C:\WINDOWS\System32\ folder leftover from the previous installation. Replace it with the one in C:\Program Files (x86)\Java\jre7\bin.
All, It was the the first time I met this kind of problem, When I installed the jdk 1.7, there is no problem found in this process. After that , I try to verify the version of the jdk . so I run the java command in the dos window. But got the result says java is not recognized as an internal or external command, operable program or batch file. Can anybody tell me why and what happen? thanks.
The Java installer does not automatically add the bin directory of the JDK to the PATH, as you seem to expect.
You'll have to do that yourself, as is explained in the JDK installation instructions:
Updating the PATH Environment Variable (Optional)
You have to set the Path variable under Start -> System to the bin folder of your java installation if you are working under Windows