Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the JRE on Windows

Tags:

java

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?

like image 844
Mike2012 Avatar asked Jul 16 '10 18:07

Mike2012


People also ask

Where can I find JRE?

They will be listed by name. All of the 32-bit programs are installed in the Program Files (x86) directory, easily accessible using Windows Explorer. Look for the Java directory within Program Files (x86) and you will find all of the 32-bit Java packages that are installed located there.


2 Answers

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\

like image 120
Martster Avatar answered Oct 19 '22 23:10

Martster


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.

like image 42
B White Avatar answered Oct 19 '22 23:10

B White