Uniform way to access %ProgramFiles(x86)% in Vista 32 bit and Win 7 64 bit
I am developing a java application and deploy it using batch file. At work, I use Vista 32 bit and at home I use win 7 64 bit. The batch file calls java.exe to do some tasks
Due to some issue with Netbeans, I am forced to do my development on 32 bit java (both at home and at work), so at home I have a 32 bit jdk installed in %ProgramFiles(x86)% on which I do my development and also the 64 开发者_StackOverflow社区bit jre in %ProgramFiles% (which is used for other stuff)
Is there any uniform way to access the 32 bit folder on both work and home computers, so I don't have to have two copies of batch files (the home one calling java.exe in %ProgramFiles(x86)% and the office one calling default java.exe (in %ProgramFiles%)
We do something like this:
set programfiles32=%programfiles(x86)%
if "%programfiles32%"=="" set programfiles32=%programfiles%
copy foo.dll "%programfiles32%"
This may surprise you, but when you execute java.exe
or javaw.exe
without specifying a path, it executes the copy in C:\Windows\system32
. These copies are actually redirectors that read registry keys to determine the latest Java version installed. However, it can be overridden via the JAVA_HOME
environment variable.
You can set environment variables per-user or system-wide in Windows under Control Panel, System, Advanced tab, Environment Variables button... or at least that's where it's located on my XP work machine. I seem to recall it's still in the same location on my Win7 home machine.
Edit: I forgot to mention this, but JAVA_HOME
's value should be the path to the main directory for your JVM/JDK. For my 32-bit XP dev box, that's C:\Program Files\Java\jdk1.6.0_24
because my dev tools need access to executables from the JDK.
精彩评论