Finding the JRE on Windows
I know this question is going to sound very stupid but here goes nonetheless. I need to bundle t开发者_如何学Che 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.
精彩评论