2013-05-16 80 views
1

我公司的軟件利用Java Access橋來正確運行。使用Java環境變量指向備用Java文件夾

我們發現,每當Java自行更新時,我們都必須再次重新安裝Access Bridge組件。

是否有一種方法可以使用環境變量指向Java Access Bridge或Java JRE,以保護我不能更新的文件夾?

+0

Java Access Bridge自Java 7 Update 6起預先安裝,因此這不應該成爲問題了。 –

回答

0

更新Java時,會將其安裝到新文件夾和%JAVAHOME%更改中。 我的系統上的JAVAHOME設置爲C:\Program Files\Java\jdk1.7.0_13,當我更新13將更改爲14

現在的問題是,當您安裝Java Access Bridge文件時,會將其複製到包含%JAVAHOME%的各種文件夾中。因此,當您更新Java時,新的Java主文件夾沒有Java Access Bridge組件。

除了重新安裝Java Access Bridge之外,你無能爲力。

請參閱安裝doco http://docs.oracle.com/javase/accessbridge/2.0.2/setup.htm#installing-jab-64-bit

+0

你會建議給一個批處理文件的某種安裝啓動JAB或類似的東西? – user222423

+0

編寫一個批處理文件來安裝JAB將是一個好主意,但我沒有給它。 – Bull

+0

我認爲我們將爲此使用批處理文件。我會張貼我們很快提出的。 – user222423

0

這是我們跟去的批處理文件:

@echo on 
cd /d %~dp0 

rem case sensitive jre - finds juice Java folder and puts to temp.txt into temp folder 
:CHKFLEX 
set temp1=%LOCALAPPDATA%\Juice\Flex 
dir /AD /b %temp1% | find "jre" > %temp%\temp.txt 

rem didnt find the jre folder in juice 
if %errorlevel% NEQ 0 goto notfound 

rem create environment variable to path found and written to temp.txt 
for /f "delims=" %%x in (%temp%\temp.txt) do set temp2=%%x 

rem path to juice subfolder created 
set temp1 
set temp2 
set "_prog=%temp1%\%temp2%" 

rem copy if files aren't there already 
:x86 
Set JAVAHOME32=%_prog% 
@echo on 
if exist "%JAVAHOME32%\bin\JavaAccessBridge-32.dll" goto theend 
copy WindowsAccessBridge-32.dll %WINDIR%\SYSTEM32 
copy JavaAccessBridge-32.dll  %JAVAHOME32%\bin 
copy JAWTAccessBridge-32.dll  %JAVAHOME32%\bin 
copy accessibility.properties %JAVAHOME32%\lib 
copy access-bridge-32.jar  %JAVAHOME32%\lib\ext 
copy jaccess.jar   %JAVAHOME32%\lib\ext 

goto theend 

rem Juice JRE folder not found 
:notfound 
echo "Alternate JRE folder not found..." 

:theend 
pause 

雖然我們確實有一個更先進的批處理文件,可以通過檢查註冊表中的Java主複製到這兩個果汁文件夾和Java文件夾路徑。以下是其中一個:

@echo on 
cd /d %~dp0 

:REGVAL 
FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime  Environment" /v CurrentVersion') DO set CurVer=%%B 
FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\% CurVer%" /v JavaHome') DO set JAVA_HOME=%%B 
Set JAVA_HOME 

:CHKFLEX 
set temp1=%LOCALAPPDATA%\Juice\Flex 
dir /AD /b %temp1% | find "JRE" > %temp%\temp.txt 

if %errorlevel% NEQ 0 goto notfound 

for /f "delims=" %%x in (%temp%\temp.txt) do set temp2=%%x 

set temp1 
set temp2 
set "_prog=%temp1%\%temp2%" 

pause 

if not exist "%systemdrive%\Program Files (x86)" (
    goto x86 
) else (
    goto x64 
) 

:x86 
Set JAVAHOME32=%_prog% 
@echo on 
if exist "%JAVAHOME32%\bin\JavaAccessBridge-32.dll" goto x86_next 
copy WindowsAccessBridge-32.dll %WINDIR%\SYSTEM32 
copy JavaAccessBridge-32.dll  %JAVAHOME32%\bin 
copy JAWTAccessBridge-32.dll  %JAVAHOME32%\bin 
copy accessibility.properties %JAVAHOME32%\lib 
copy access-bridge-32.jar  %JAVAHOME32%\lib\ext 
copy jaccess.jar   %JAVAHOME32%\lib\ext 

:x86_next 
if exist "%JAVA_HOME%\bin\JavaAccessBridge-32.dll" goto theend 
copy JavaAccessBridge-32.dll %JAVA_HOME%\bin 
copy JAWTAccessBridge-32.dll %JAVA_HOME%\bin 
copy accessibility.properties %JAVA_HOME%\lib 
copy access-bridge-32.jar %JAVA_HOME%\lib\ext 
copy jaccess.jar   %JAVA_HOME%\lib\ext 

goto theend 


:x64 
Set JAVAHOME32=%_prog% 
Set JAVAHOME64=%_prog% 
@echo on 
if exist "%JAVAHOME64%\bin\JavaAccessBridge-64.dll" goto x64_next 
copy WindowsAccessBridge-32.dll %WINDIR%\SYSWOW64 
copy WindowsAccessBridge-64.dll %WINDIR%\SYSTEM32 
copy JavaAccessBridge-64.dll %JAVAHOME64%\bin 
copy JAWTAccessBridge-64.dll %JAVAHOME64%\bin 
copy accessibility.properties %JAVAHOME32%\lib 
copy access-bridge-64.jar  %JAVAHOME64%\lib\ext 
copy jaccess.jar %JAVAHOME64%\lib\ext 

:x64_next 
if exist "%JAVA_HOME%\bin\JavaAccessBridge-64.dll" goto theend 
copy JavaAccessBridge-64.dll %JAVA_HOME%\bin 
copy JAWTAccessBridge-64.dll %JAVA_HOME%\bin 
copy accessibility.properties %JAVA_HOME%\lib 
copy access-bridge-64.jar  %JAVA_HOME%\lib\ext 
copy jaccess.jar %JAVA_HOME%\lib\ext 
goto theend 

:notfound 
    echo "not found..." 

FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment" /v CurrentVersion') DO set CurVer=%%B 
FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\%CurVer%" /v JavaHome') DO set JAVA_HOME=%%B 

set CurVer 
Set _prog=%JAVA_HOME% 
set _prog 

if not exist "%systemdrive%\Program Files (x86)" (
    goto x86 
) else (
    goto x64 
) 


:theend