This one has me pretty frustrated...
I've installed the Java JDK and got the command line successfully pointed at it. When I open jar files through the terminal it uses the correct JDK to run the jar.
However, when I attempt to open the same jar via double-clicking it in Finder, it uses a different Java executable! In this case, the one that's located at /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java.
How can I change what Java executable Finder is using?
System Preferences > Java Control Panel > Java > View... :
Related
I installed the default java extensions, downloaded jdk-13.0.2 windows installer, updated the path and JAVA_HOME in the environment variables. After searching for answers, I added the settings in VSCode for java.configuration.runtimes and java.home. After all that, when I try to run my java file in VSCode, it gives me the message "Java 11 or more recent is required to run the Java extension. Please download and install a recent JDK... Source: Debugger for Java (Extension)". I'm not sure what I'm missing or what I did wrong. I attached a screenshot of the VSCode settings.
Screenshot of VSCode settings
If you didn't add java to Environment Path, java.exe couldn't be recognized and used except under the java installation directory, and that's why the java extension think you didn't install the required JDK.
Add JAVA to PATH. You can refer to PATH IN The Java™ Tutorials
Press Ctrl+Shift+` in VS Code to open the integrated Terminal,
then run java --version to check if it's the right one;
Install Java Extension Pack in VS Code Extension Marketplace, which includes necessary extensions you need during development.
It seems restarting my computer took care of it. I verified that java was working outside of VS Code but VS Code wasn't wanting to work with java. No changes were made but when I reopened the project it works.
I recently noticed that my PATH setting in Windows had incorrect pointers to older versions of Java. What is odd is that the java -version command still works at the command prompt and it gives the version of Java that does correspond to the latest JRE I have installed. This is also the version represented in Control Panel and it is the VM version referenced by Eclipse. What I'm confused about is how does the command prompt know where to find the java executables if the path is set incorrectly?
There is no mystery. There are going to be at least two versions of Java installed on your computer: The one you installed manually, and the one Windows uses (most likely inside the \system32 folder).
when you type the java command at the command prompt, the operating system (windows) resolves this command by: 1) executing the command located on the current directory, 2) finding the command in one of the paths declared in the PATH.
I have multiple Java versions installed on my computer. The one I want to use to develop software is the one I made sure is declared first on my PATH variable.
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.
So I've been getting this error when trying to start Eclipse:
"No java virtual env found after searching the follow locations:
/absolute/path/to/jre6/bin"
I checked the control panel and I got JDK (Update 21 / 64-bit) installed.
However, JDK is installed is installed on my primary drive (the sdd with Windows on) whereas Eclipse is unzipped and executed from my secondary hard drive.
How to I tell eclipse to find Java on my c-drive instead of the d-drive where it's located?
Thanks in advance!
I would suggest you uninstall all versions of Java you have installed and then installed the one you want to use.
Another option is to tell eclipse which Java to use. For example: eclipse -vm c:\path\to\jre\bin\javaw
Locate the eclipse.ini file and ensure that the variable -vm is correct (
FAQ How do I run eclipse):
If a JVM is installed in the eclipse/jre directory, Eclipse will use it; otherwise the launcher will consult the eclipse.ini file and the system path variable. Eclipse DOES NOT consult the JAVA_HOME environment variable.
I was trying to run a project in my local machine.
I tried to load this jnilib file which I got from a running instance of this project on my Mac 10.6.2,
System.load(lib.getAbsolutePath());
then I got this exception thrown:
java.lang.UnsatisfiedLinkError, mach-o but wrong architecture
I have check the jnilib with file command:
libScreenMatchProxy.jnilib: Mach-O dynamically linked shared library i386
I guess this is because the jnilib file is compiled in 32bit but the Java comes with Mac10.6 is 64bit. So I go to Java Preference and set Java to use 32bit first. But it didn't work.
As mentioned above, this jnilib file is copied from a running instance of the project on my Mac, so it should work. I don't understand why it working in the installed application but not in my Eclipse.
Adding "-d32" to the VM argument from Run Configuration will force Eclipse to call Java in 32bit mode. That will solve this problem.