Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Auctomatically Detect the Latest Java Version Solution

Creator
Creator

There is a file within the TeamCenter10 called tem_init. That has a hard coded path, but when a user updates to the latest version and destroys the version that was pointed to it causes a JRE path error. I however found a solution that automatically detects the latest JRE version. It is working and tested on diffrent OS Win7 and up.

 

Here is the code:

 

Just remove whatever thats in tem_init.bat and place the code below.

 

Set "baseKey=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment"
Set "regVal=JavaHome"
REM Created by Ryan Tarson @rtarson
Set "javaDir="
For /F "Tokens=2*" %%A In (
    '"Reg Query "%baseKey%" /S /F "%regVal%" /V 2>Nul|Find /I "%regVal%""'
) Do Set "javaDir=%%~B"
If Not Defined javaDir (Echo Java directory not found) Else (
    set TC_JRE_HOME=%javaDir%)

 

3 REPLIES 3

Re: Auctomatically Detect the Latest Java Version Solution

Genius
Genius

Hi,

Thanks for sharing !

However I'm not sure of the utility of this method. The tem_init.bat is only used for the Environment Management. You seem to say that a user can upgrade the JRE on his workstation and then having this changed .bat is enough in order to have a working Teamcenter/Java couple.

If so, I think you still need to upgrade the JRE version through TEM (no command line, sadly). It is required when some speicific modules are installed at least, if not for a basic client. Your method may work to launch Teamcenter but I think you can get into trouble.

Modifying the tem_init.bat is useful when the java version has been changed without migrating jre version beforehand.

Best regards.

Re: Auctomatically Detect the Latest Java Version Solution

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

"Migrate to a different JRE" is mostly only changing the path contained in "TC_ROOT\install\tem_init.bat".

We have the following content in tem_init.bat to support external clients where Java is set to automatic update.

for /d %%D in ( "%ProgramFiles%\Java\*" ) do if exist "%%~D\bin\java.exe" set TC_JRE_HOME=%%~sD

Also remember that tem_init.bat is called by many other batch files to retrieve the Java path, so this is usually a change to just one file to reduce maintenance.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.2, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0

Employees of the customers, together we are strong ;)
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide

Re: Auctomatically Detect the Latest Java Version Solution

Creator
Creator

So far we really havn't expirenced any issue. I looked at the migration log when migrating the JRE and I noticed that there isn't really much that is changed. I also searched siemens TC10 folder I really havn't founded much that directs to the JRE location other then that batch file. 

 

I could be wrong I will have to keep that in mind now. So far that script works and it works good when someone accidently updates the JRE