Solved

Using Java environment variables to point to alternate Java folder

Posted on 2013-05-17
9
302 Views
Last Modified: 2013-06-18
My company's software utilizes Java Access bridge to function correctly.

We found that every time that Java updates itself, we have to once again re-install the Access Bridge components.

Is there a way to use an environment variable to point to either the Java Access Bridge or Java JRE to a folder that I can protect from getting updated?
0
Comment
Question by:James_Clements
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39175447
I thought i'd already answered this question ...
0
 

Author Comment

by:James_Clements
ID: 39175569
Your suggestion was that the Java Access bridge documentation was incorrect.  It did not help with our customer.  I need a solution to help this customer.

Currently, we are considering a batch file that can somehow check appropriate folders for Java Access Components and reinstall if necessary on startup but the exact parameters for such a file have not been laid out yet.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39175681
Your suggestion was that the Java Access bridge documentation was incorrect.  I
No - that wasn't my suggestion. My suggestion was to install a JDK
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:James_Clements
ID: 39175772
We did try installing the JDK but it is not clear how to use the folder and whether or not that folder will be updated automatically.
0
 
LVL 1

Expert Comment

by:dcpetersonp
ID: 39192091
If you're using Java7 update 6, access bridge comes bundled which should make it easier to manage.
https://www.ssbbartgroup.com/blog/2012/08/30/jre-7-update-6-now-comes-bundled-with-the-java-access-bridge/
0
 

Author Comment

by:James_Clements
ID: 39211208
That was an interesting find but attempts to use this function were not successful.  We saw confirmation that java bridge was enabled as it says but using our software was not successful until we manually copied the JavaAccessbridge files themselves.  

We have prepared a very extensive batch file to find the correct Juice folder and to also check the registry for the Java installed files so we can update both locations.  I'll post it up once we are sure it is working successfully.
0
 

Accepted Solution

by:
James_Clements earned 0 total points
ID: 39245177
This is the batch file we went with:

    @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

Although we did have a more advanced batch file that can copy to both the Juice folder and to the Java folder by checking the registry for the java home path.  Here is that one:

    @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
0
 
LVL 1

Expert Comment

by:dcpetersonp
ID: 39245393
out of curiosity, did you try the latest java 7 or did you only try j7u6?
0
 

Author Closing Comment

by:James_Clements
ID: 39255608
Took longer than expected to resolve this.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question