I am Not able to find JRE files in Program Files? - java

I am trying to download jdk in my windows 10 64 bit OS system. Once installation is completed I try to set the path. But I am not able to find the jre files in Program Files. But I want to jdk and jre both files to be in the Program files. In my colleagues systems jdk is installed in program files. In their system both files in Program Files like following:
C:\Program Files\Java\jdk-1.8.0_51
C:\Program Files\Java\jre-1.8.0_251
But in my system files look like following.
C:\Program Files (x86)\Java\jre1.8.0_261
C:\Program Files\Java\jdk-14.0.2
The path should be my colleagues format. Please help me on this.

First of all, your colleague is using JDK 8.
Download Oracle JDK 8(LTS) for here.
https://www.oracle.com/in/java/technologies/javase/javase-jdk8-downloads.html.
Or you can use Amazon Corretto JDK 8 which is a nice choice as it automatically set environment for you. Just install, develop and run applications.
Now, JDK comes with JRE included. So, you don't need to install JRE on your system.
Set the JAVA_HOME to <path of jdk>/bin or JRE_HOME to <path of jdk>/jre
That's all.

Related

How to run jar files in Mac using JRE?

Mac OSX 10.11.14 (El Capatin) does not ship with Java, either the complete development kit (JDK) or the run-time environment (JRE). My need was to just run a .jar file and not for complete Java development. So I downloaded the JRE from here, which is a much smaller file compared to JDK (quite obviously).
This SO answer says that JRE is enough to run jar files.
After installation of JRE I couldn't locate the directory where installation happened or run java command to execute files on my mac. How do I run jar files now?
To run java application you can either use
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
or (as you found)
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
In any case, if you need to run java often, you should set JAVA_HOME in either your ~/.bash_profile or ~/.profile and amend the PATH to include the bin directory.
After JRE installation, the correct path is:
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin
But now, how do I run the java command? It seems like the java file located in the directory above is not an executable.

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.

javac not working on Win 8.1

I installed jdk 8_u25 on my Windows 8.1 ,but commands javac and javap aren't working. I went to environment variables and changed the value of Path to
C:\Program Files (x86)\AMD APP\bin\x86_64;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Java\jre1.8.0_25\bin​
and still isn't working. My program files in on C: itself. Kindly help. Thank You.
When you install a JDK on Windows, as well as installing the JDK it also installs a separate "public" copy of the JRE for use by tools like web browser Applets and Java Web Start.
C:\Program Files\Java\jre1.8.0_25\bin​
looks like the bin directory of this public JRE installation rather than the JDK itself, and the public JRE does not include javac.
You need to add the JDK bin directory to your path instead of the public JRE one.

How to silently install Java JDK into a specific directory on windows

On my development machine I always have to install Java 6 and Java 7 and I have to install each JDK in both, the 32 and 64 bit version, for testing purposes. Since the frequency of Java updates seems to be getting more and more ridiculous (twice per week by now?) each update requires me to un- and then re-install 4 JDKs. So this is getting really quite annoying and I would thus like to script this entire process.
My problem is, that by default each JDK versions installs into a directory-path that contains the update-number (default: "C:\Program Files\Java\jdk1.6.0_<update-nr>\"). To spare me from having to adapt tons of build-scripts I always manually strip the trailing "_<update-nr>" from the installation path and always install into the same "C:\Program Files\Java\jdk1.6.0" or "C:\Program Files\Java\jdk1.7.0", resp., for the 64-bit versions and into C:\Program Files (x86)\Java\jdk1.6.0" or "C:\Program Files (x86)\Java\jdk1.7.0", resp., for the 32-bit versions.
While I found out, how to specify the installation directory for a JRE installer (i.e. the Java runtime):
<jre-installfile>.exe [/s] [INSTALLDIR=<drive>:\<JRE_install_path>]
[STATIC=1] [WEB_JAVA=0/1] [WEB_JAVA_SECURITY_LEVEL=VH/H/M/L]
I did not yet find a similar description how to specify the installation directory for the JDK installer.
Does anyone know if and how one can specify the install path for the JDK installer, so that one can direct a silent JDK installation into a specific installation directory?
I could successfully install both x64 and x86 versions of JDK 8 update 60 including a public JRE with these commands:
Here JDK 1.8.60 (x86) with source code is going to C:\Java\x86\jdk1.8.0_60 and JRE to C:\Java\x86\jre1.8.0_60:
jdk-8u60-windows-i586.exe /s ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature" INSTALLDIR=C:\Java\x86\jdk1.8.0_60 /INSTALLDIRPUBJRE=C:\Java\x86\jre1.8.0_60
In a similar way, JDK 1.8.60 (x64) with source code is going to C:\Java\x64\jdk1.8.0_60 and JRE to C:\Java\x64\jre1.8.0_60:
jdk-8u60-windows-x64.exe /s ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature" INSTALLDIR=C:\Java\x64\jdk1.8.0_60 /INSTALLDIRPUBJRE=C:\Java\x64\jre1.8.0_60
See Oracle JRE installer options
I just found this article while searching... it specifies a parameter for INSTALLDIR.
http://makeitfaster.wordpress.com/2011/03/25/java-jdk-silent-install-on-windows/
jdk-7u2-windows-i586.exe /s ADDLOCAL="ToolsFeature,SourceFeature" INSTALLDIR="%CD%\jdk7u2"
I unfortunately had already installed on my dev machine, so i couldn't test...
One approach to avoid rewriting directories in scripts is to use symlinks (junctions on NTFS).
First, download the junction utility from SysInternals here:
http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx
then unzip, copy to some directory on the PATH, and run once to accept the licence.
Then you can create symlinks easily:
junction "C:\Program Files\Java\jdk1.6.0" "C:\Program Files\Java\jdk1.6.0_37"
junction "C:\Program Files (x86)\Java\jdk1.6.0" "C:\Program Files (x86)\Java\jdk1.6.0_37"
To delete some symlink:
junction -d "C:\Program Files\Java\jdk1.6.0"
You can also use mklink ( http://technet.microsoft.com/en-us/library/cc753194.aspx ) instead (and del for removal), but I prefer the simplicity and clarity of junction.
Try:
jdk-7u2-windows-i586.exe /s INSTALLDIR=\"C:\Program Files\JAVA\JDK\"
I just discovered a regression in the JDK7 installer that causes it to ignore INSTALLDIR. The last correct version is update 21.
I have filed a bug report and will let you know once Oracle replies.
UPDATE: It turns out that this was caused by an corrupt (incomplete) JDK installation. Once I uninstalled this version (Add/Remove Programs) the new installation ran just fine.
This is the way that works for me for JDK_7u55. I opted to have the JRE installed too:
PowerShell Commands
$strJavaInstallExe=<Your JDK executable>
$strJavaInstallDir=<The directory you want the JDK and JRE to install to>
$cmdInstallJava=$strJavaInstallExe+' /passive /log "'+$strJavaInstallDir+'\install.log" ADDLOCAL="ToolsFeature,SourceFeature,PublicjreFeature" INSTALLDIR="'+$strJavaInstallDir+'" INSTALLDIRPUBJRE="'+$strJavaInstallDir+'"'
Invoke-Expression $cmdInstallJava
Hope this helps!
EDIT - easier way
Execute jdk-7u60-windows-x64.exe /passive /log install.log INSTALLDIR:c:\pippo
Works with 7u45 and 7u60
OLD answer
The exe contains the msi installer. To extract is (for sure there are more elegant methods, but I know only this one)
Run the exe manually - you need to do it only the first time, to convert it to an msi
Grab the msi (and all other.cab file) from C:\Users\AppData\LocalLow\Sun\Java\jdx.x.y\jdk.x.y.z.msi
run msiexec /i jdkx.y.z.msi /passive INSTALLDIR:c:\pippo
file jreinstall.bat (example: storage in desktop) (replace jre for jdk)
#echo off
start /w %UserProfile%\Desktop\jre-8u65-windows-x64.exe /s
setx JAVA_HOME "C:\Program Files\Java\jre1.8.0_65"
exit

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