LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding Window's java program path in LabVIEW

Solved!
Go to solution

I'm writing some software that depends on various java files being installed correctly into the lib/ext folders and bin folders of the current version of the java runtime installed.  I'd like to be able to check if these files are in place and give an appropriate error message in my LabVIEW code if they are not.  However, the path to these folders may be different on different machines depending on the the version of java installed and the version of windows used (e.g. C:\Program Files (x86)\Java\jre7   vs.  C:\Program Files\Java\jre6).  I'm using the 32 bit version of LabVIEW and the System Exec.vi to make all my calls to java.  Does anyone know of a way directly from LabVIEW or a command in Windows I could use from System Exec.vi to find these paths?  Thank you.

0 Kudos
Message 1 of 8
(4,847 Views)

Hi,

 

I assume the best way to do this is to read the registry, in HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.x there seem to be a value called : JavaHome that is a path.

 

Hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 8
(4,839 Views)

Yea, this is what I was finding after much googling and playing around...

 

So I just have to do the windows command java -version, parse the results for the current java version, use that info to generate a query for the reg command and then parse those results... what could possibly go wrong... Smiley LOL

0 Kudos
Message 3 of 8
(4,832 Views)

I think you should stick to registry only, to get the java version, just read the "CurrentVersion" value in the "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" key.

Then use the "CurrentVersion" string to build the new key :and read the JavaHome value.

 

Enjoy! 


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 4 of 8
(4,828 Views)

Good point.

 

What about 32 vs. 64 bit operating systems?

 

I only want 32 bit java, however I found that on 64 bit windows 7 the registry keys are under "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\..." and 32 bit windows xp is under "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\.." Do you know where the registry key is to figure which version of windows I'm dealing with?

 

Thanks again!

0 Kudos
Message 5 of 8
(4,815 Views)

I have used JSmooth in the past, maybe it will help you out.

 

http://jsmooth.sourceforge.net/index.php

0 Kudos
Message 6 of 8
(4,811 Views)

@GollumGTH wrote:

Yea, this is what I was finding after much googling and playing around...

 

So I just have to do the windows command java -version, parse the results for the current java version, use that info to generate a query for the reg command and then parse those results... what could possibly go wrong... Smiley LOL


There's functions for accessing the registry in Connectivity -> Windows Registry Access

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 7 of 8
(4,799 Views)
Solution
Accepted by topic author GollumGTH

In case anyone else has this issue:

 

Use the LabVIEW functions in Connectivity > Windows Registry Access (Thanks Yamaeda)

To access "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" (Thanks 

0 Kudos
Message 8 of 8
(4,793 Views)