Java not finding the proper path - java

I am having a problem with running java from cmd.exe.
When i type in 'java' this errors shows:
Error: could not open `D:\Program Files (x86)\Java\jre6\lib\i386\jvm.cfg'
The problem is, my java is not in jre6, but in jre7. The jre6 folder doesn't even exist anymore.
I've checked the path and all other environmental variables and java was not mentioned anywhere. So I updated path to point to D:\Program Files (x86)\Java\jre7\bin but that didn't help.
I am running Windows 7 64-bit so I also tried running java from 64-bit cmd.exe but it didn't help.
Is there anywhere else except path to look and change the way Windows looks for java?

The problem is that older JDKs copy java.exe among some other Java executables into C:\Windows\System32 which happens to be on the PATH before the new JDK/JRE location.
The solution is to delete java.exe and other Java related executables from System32 as they aren't required any more. This could however potentially break applications that depend on the older JDK/JRE and hence they may need to be re-configured.

Related

Matlab Compiler Runtime installation file cannot locate Java Runtime Environment

A collaborator has sent me some Matlab code which requires an old MCR version (7.14). I have an installation binary from them, but when I run it I am immediately faced with the message
No Java Runtime Environment(JRE) was found on this system
Has anyone experienced this before? I cannot get around the problem. I have JRE installed. I am running Ubuntu 18.04.
Thank you for any help.
One possible cause may be that JAVA_HOME environment variable is not set, or that it is set incorrectly. The variable should point to the installation directory for the JRE / JDK whose java command you are running.
(Note: a correct JAVA_HOME is never a bin directory, so if you have set your $JAVA_HOME to a bin directory you have done it wrong!)
Thus, the solution may simply be to set the JAVA_HOME environment variable (correctly) in your shell before running the MCR installer.
I have used it [the MCR installer] successfully on numerous other Ubuntu machines.
This is suggestive to me that your problem is an incorrect JAVA_HOME ...
Another possible solution would be to follow the instructions in the MATLAB documentation for doing a "non-interactive" install of MCR.
There is apparently a README file in the zip file. It may contain information about command line options for the installer that relate to the version you are using.
Finally, I suspect that the install command is actually a shell script. There may be clues in the script about command line options and other alternatives for installing.

Installed latest JDK 1.8.0, but my Javac -version still shows an older version (Windows 7 - 64)

I've been attempting to install NativeScript with Angular with this tutorial for the past two days, and I keep running into problems surrounding the Android SDK not installing correctly and freezing, and finally re-installing the latest JDK and JVE before attempting to install Android Studio. As I researched the problem I think I found the culprit:
When I run Javac -version I keep getting an older version of JDK, it states: javac 1.6.0_45 However I have the latest version of Jdk 1.8.0_102.
I researched the problem, but only found either complex solutions invilving the variable path, or MAC solutions. What can I do to update the JDK when I run Javac -version?
User Variables: PATH
cmd> set PATH=%PATH%;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%NVM_HOME%;%NVM_SYMLINK%
System Variables: PATH
JAVA_HOME%/bin;C:\Python27\;C:\Python27\Scripts;C:\Ruby22-x64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.6.0_45\bin;C:\Program Files (x86)\Beyond Compare 3;C:\Program Files (x86)\Brackets\command;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\ProgramData\chocolatey\bin;C:\Program Files\Java\jdk1.8.0_102\bin;C:\Users\Godsnake\AppData\Local\Android\android-sdk\tools;C:\Users\Godsnake\AppData\Local\Android\android-sdk\platform-tools;%NVM_HOME%;%NVM_SYMLINK%;C:\Program Files\nodejs
Note:, I'm a complete noob at playing around with the Windows path, and I don't really know anything about the environment variable, but I see that the paths of certain applications that I have installed all appear in the system variables: Python, Node, Ruby, AngularJS2, AndroidSDK.. That being said if anyone can me some guidance on the uses, best practice, and differences between user variable and system variable that will be an added bonus. And please give me instructions like I'm a complete beginner when it comes to messing around with the path. Thanks!
Your system path still contains 1.6.
C:\Program Files\Java\jdk1.6.0_45\bin;
It has both, try removing this and just having 1.8. (already in there)
I removed the PATH entry which pointed to java JRE in Oracle client directory, leaving just 1 in PATH pointing to correct java JDK/JRE , and Kaboom it worked.
Use where java in cmd. You will find different versions of java. Leave the one you want to use and uninstall others.

Can't install Java JDK

Ok, this is embarrassing, but I can't install Java. I have no experience in Java so any help appreciated.
So as ussual I install Java JDK (The JRE I think is already there before) I have jre7 and jdk1.8.0.0_05
I have install it, but Java still not in my computer
Here's some desperate cmd check
>C:\>WHERE java
>INFO: Could not find files for the giving pattern
>C:\>java
>'java is not recognized as an internal or external command, operable program or batch file.
Where my java folder is C:\Program Files (x86)\Java\jdk1.8.0.0_5
On my desperation I created the variable JAVA_HOME on the given directory. Afterward, I tried this.
>C:\>echo %JAVA_HOME%
%JAVA_HOME%
I was expecting the cmd to echo the directory.
The variable PATHEXT has the following in it:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Clariffication:
I tried to reinstall the Java Jdk Installer with Windows Installer, but no luck.
If this matters, I'm running from Windows 7.
I tried to learn from Here
After closer inspection, I can run java and javac after going all the way into the directory (so inputing java outside the bin will do nothing good)
Add C:\Program Files (x86)\Java\jdk1.8.0.0_5\bin to your PATH variable
Here is how mine is
I think you may have not added JAVA_HOME environment variable, and/or to PATH environment variable neither.
Give a read to this article
http://www3.ntu.edu.sg/home/ehchua/programming/howto/jdk_howto.html
Regarding you last comment, i think you should put the java directory right infront of all the other directory because, if you were to install another version of java it might not be used if you place it behind.
(For Advanced Users Only)
I suggested that you place the JDK bin directory in front of "c:\windows\system32" and "c:\windows". This is because some Windows systems may have an out-dated copy of JDK/JRE in these directories. Do a search for "java.exe", and you will be amazed by the findings.
You could read "Java Applications and Environment Variable" for more discussions about PATH environment variable.
I also recommend that you define an environment variable called JAVA_HOME, which contains the JDK installed directory, and include the JDK bin directory in the PATH via JAVA_HOME, i.e., PATH=%JAVA_HOME%\bin;.....

Java Runtime Environment not found error

I've been working on Aptana Studio and some JRE required software for a bit of time now , but since yesterday something quite odd happened, as suddenly the software that requires it threw me an error No Java virtual machine was found . Last thing I did before that was restoring my system files permissions thought safe mode as I had some trouble with that , could this have anything to do with it ?
I've tried installing JRE once again , no results. However when I run
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version
I do get the following
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)
Aptana gives me the following error
No Java virtual machine
was found after searching the following locations:
/Applications/Aptana Studio 3/AptanaStudio3.app/Contents/MacOS/jre/bin/java
java in your current PATH
And other software such as Spine won't simply start.
My .bash_profile is the following :
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
PATH="/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin:${PAT$
export PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
The output of echo $PATHis the following
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
The output of echo $JAVA_HOME is the following
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
And Java invocations on the terminal work.
Guidance will be highly appreciated.
After trying Peter's suggestion the problem persisted but now in another context : "/System/Library/Frameworks/JavaVM.framework" does not contain the JNI_CreateJavaVM symbol"
After struggling for many hours, and reading about people with the same issue opting to re-install the entire OS , decided to examine the issue from another perspective, the thing I first mentioned here that I believe went unnoticed was that I restored my permissions before this happening, so what I did was the following.
After reading a bunch of articles about Apple no longer providing Java support themselves but Oracle providing it, reasoned through it and realized that perhaps paths (Often called directories) from Apple's final Java release may have not been strictly the same as the new Oracle releases, so decided to wipe out all recent Oracle Java Runtime Environment that I found on /Library/Java/JavaVirtualMachines and delete the Java Applet Plugin from /Applications (Just search for it on your /Applications path) .
Installed Apple's last stable release from the following link.
Located where Apple located their Java releases : /System/Library/Frameworks/
My particular interest was the Java Runtime Environment , so I explored the JavaVM directory on /System/Library/Frameworks/
Found out that all Apple's JRE previous releases reside on a directory called Versions that is within /System/Library/Frameworks/JavaVM.framework directory, here's where I noticed something rare, for some reason at the moment I restored file permissions from my Disk Utility Application , this directory was made inaccessible (By not giving the root user permissions to access anything in itself).
Went to my terminal console and inside the JavaVM.framework directory modified the permissions to that directory to be accessible for all users by running the following command chmod -R 777 Versions.
After executing these actions I went straight to my JRE-Required software and attempted to open it , success!
Things to learn from the issue.
Oracle's Java JDK/JRE are located in different paths from Apple's. (If you are struggling with some other issue, verify your Java version to determine your Java installation directory)
Apple's disk utility application might define different permissions than expected for some files. (After restoring permissions verify that everything's working fine, if not this may be the cause of your problems.)
Looks like AptanaStudio (Eclisebased right?) assumes that you have a JRE inside the Aptana directory (/Applications/Aptana Studio 3/AptanaStudio3.app/Contents/MacOS/jre/bin/java)
I assume that there is nothing there. Simplest way would be to symlink your existing JRE installation to that directory:
ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre /Applications/Aptana\ Studio\ 3/AptanaStudio3.app/Contents/MacOS/jre
Or you could start Aptana from the terminal and specify the path to java with -vm:
./aptana -vm "/path/to/java/bin/directory"
Environment variables that must be available to GUI applications are a bit tricky in OsX (at least in my experience).
It is possible to set global PATH (and other variables) in /etc/launchd.conf, see for example here and /etc/paths.d see here.
Simple Solution
For Windows:
1.download the JAVA runtime environment x86(32bit) version else you will get an error with dll file from here http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
Extract the folder out of the .tar file you downloaded.
Rename the JRE folder to "jre"
Then paste it in to this directory
C:\Users\"User Name"\AppData\Roaming\Appcelerator\Aptana Studio
This worked for me
I uninstalled all my Java JREs and JDK for Windows 10. Then I downloaded Aptana again and let it install Java for me. I think JAVA 8 was my problem, but this worked and I can still install the other versions again.

Finding the JRE on Windows

I know this question is going to sound very stupid but here goes nonetheless. I need to bundle the new version of the JRE with my applicaiton and I cannot find either a version of the JRE that is not in .exe nor can I find where the jre is installed to on Windows 7 (windows 7 search cannot find anything so it is not helpful). Can anyone tell me where I can download a version of the JRE the would be good to bundle or where I can find the path that windows installed the JRE too?
Not sure about Windows 7 but on Windows XP the installation defaults to C:\Program Files\Java\jre6
corsiKa is correct about Windows 7
I found that the file path for jre is
C:\Program Files (x86)\Java\jre7
For my purposes I needed to install the Connector/J JDBC driver in the ext directory.
jre7\lib\ext\
Alternatively, install a JDK, if you haven't done it yet, and take the jre folder in its installation directory.
The JDK can also install it in Program Files (64-bit on 64-bit Windows, always on 32-bit Windows) or Program Files (x86) (32-bit on 64-bit Windows) as explained above.
It also installs java.exe, javaw.exe and javaws.exe in C:\Windows\system32
It will be the last installed version...
I have found another, more generic solution that I'm using in Powershell. The problem is that Java is now using symlinks to java, javaw and javac, so you can't always rely on using "where.exe java" because it returns the symlink.
I now rely on Java to report where it's actually running from by using verbose mode and parsing the output.
$javapath=((java -verbose -version | ? {$_ -match "Opened" }).replace("[Opened ","")).replace("\lib\rt.jar]","")
It will find the path that java reports it's actually using and return the installation directory. The only problem I haven't quite resolved is that it outputs extra information because of the "-version" option, but the only other option is the help, which is worse. However, when run from a script, the console output can simply be ignored. If someone else has a way of keeping it quiet, I'd like to hear it.

Categories