Third party application utilizing Java portion of registry and environmental variable
Hello All,
I have a interesting question and hopefully it is has simple solution. We are getting ready to deploy an application to the Enterprise here. This application requires Java and well the application also uses the HKLM\Software\JavaSoft\Prefs key to store its configuration/preferences. Now I know Java reads things differently than windows so to speak. For Example:
In the Windows registry if I was going to store a Server name under the Javasoft\Prefs key it would be as follows
Type=RegSz
ValueName=ServerName
Data= /S/E/R/V/E/R-1
One of the values we are trying to store requires a value that is a filepath. The filepath we would like to use is basically a subfolder under the User's my documents folder so lets call it User1\My Documents\Application1
So again my understanding is that it would be
Type=RegSz
ValueName=App1FilePath
Data=//C://Users/User1/My /Documents/Application1
I am able to set this value in a msi/mst. However and here is where my question is I really do not want to hardcode to drive letter. I would prefer to use a Java Environmental Variable that basically would set to the current user without hardcoding drive letter or user with the rest being:
??This would be EnvVar?? /My /Documents/Application1/Temp
Is there a way to do this or am I stuck hardcoding to drive letter and user.
Re: Third party application utilizing Java portion of registry and environmental vari
System.getProperty("user.dir"));
Re: Third party application utilizing Java portion of registry and environmental vari
Quote:
I would prefer to use a Java Environmental Variable
Also Look at the System class. It has a method for getting the value of an Environment variable.
Re: Third party application utilizing Java portion of registry and environmental vari
I would rather use an environmental variable also....
Let me try to make this a little clearer...
So currently in the registry I have a regsz entry that goes like this:
temp value=/C:///Users//user01///My /Documents///Applicationname///temp
Okay now instead of what's above I would like to use something like:
Javaenvironmentalvariable(Users)+//Javaenvironmentalvariable(currentuser)///My /Documents///Applicationname///temp
now if one variable will cover the current user in windows thats fine two
unless i am misunderstanding the first poster and he is telling me to use something like
///user.dir//My /Documents///Applicationname///temp
Re: Third party application utilizing Java portion of registry and environmental vari
The reason for all this just to explain is one I never like to hardcode a drive letter. Two the the drive we are using is going to be a network drive which is fine for users but admins do not have that same luxury. So while hardcoding would work for users. Admins would get an error and if for some reason down the line they change what drive letter your using for that network drive then everybody gets an error.
Re: Third party application utilizing Java portion of registry and environmental vari
Can you write a test program to show what you are trying to do?
I don't see any problem building a String by concatenating the values of Environment variables with other Strings.
How are you going to use the String that you build?
Re: Third party application utilizing Java portion of registry and environmental vari
Norm all this is, is a string value for a registry storing a filepath location. The default by the program sets it to /C:///Users//user01///My /Documents///Applicationname///Temp
I just want to get away from hardcoding it. I can hardcode it in the registry to the network drive letter they are currently using. I just hate to do that. I was hoping there was a standard java environmental variable for basically C:\Users\CurrentUserName\ so basically the registry entry would be Variable///My /Documents///Applicationname///Temp
Re: Third party application utilizing Java portion of registry and environmental vari
Quote:
a standard java environmental variable
AFAIK Java doesn't set any Environment variables. It's up to the users.
Try this to see what's available from java:
Code :
Properties props = System.getProperties();
props.list(System.out);
Re: Third party application utilizing Java portion of registry and environmental vari
No it doesn't your correct. Howevery my understanding is that java doesn't read the registry the same as windows does
so for example in windows
I can use %USERNAME% well Java doesnt understand that
If I set a filepath in the windows registry it will usually use the following pattern
app1tempfolder regsz c:\Users\user01\My Documents\App1\Temp
Well Java doesn't understand that so it would be transformed to
app1tempfolder regsz /C:///Users//user01///My /Documents/App1/Temp
thats fine but what I am looking to do is basically wildcard the /C:///Users//user01 that would apply to whoever the current user is and that Java can read and understand.
Re: Third party application utilizing Java portion of registry and environmental vari
While the app itself is not Java it relies on Java's JavaSoft/Prefs key to hold and store configuration information
Re: Third party application utilizing Java portion of registry and environmental vari
Did you try the code I posted?
Re: Third party application utilizing Java portion of registry and environmental vari
No I am going to test here in a couple
Re: Third party application utilizing Java portion of registry and environmental vari
Perhaps your request is blocked by security.
This link may help