Solved

Java config file option -Duser.home

Posted on 2013-11-11
10
933 Views
Last Modified: 2013-11-12
Hello experts

We have a customer using a java based application which uses the default userfolder as working directory.
We found the option to add to the config file following command:
-Duser.home=C:\temp
Now this is working just fine, but we struggle to set the directory to another userspecific folder like %temp%. Is there a way to let java resolve windows system or user variables?

We can not use the default setting since all userfolders are redirected to a network share now when the users starts the application on his notebook and the terminal server there is a conflict due files that are already in use.


Thank you for your help

cheers
Ben
0
Comment
Question by:ABX-CEE
  • 5
  • 5
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39638842
Now this is working just fine, but we struggle to set the directory to another userspecific folder like %temp%.
Is there such an env var?

echo %temp%

Open in new window

0
 

Author Comment

by:ABX-CEE
ID: 39638904
Yes. When I open a cmd prompt %temp% is set right.

If I put this in the config file of the java application (which was not written by us) it will create a folder named %temp% in the applications root directory.

I also tried things like:
-Duser.home=System.getProperty("user.home")
but then I get a folder named System.getProperty("user.home") in the root directory of the application (this test was to see if java will resolve variables).
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39638979
Well in order to expand the variable correctly, you must use a shell. How are you currently launching the app?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:ABX-CEE
ID: 39639089
Currently through a shortcut in the start menu.
I already played with command line options in the shortcut the problem is, that some users are used to launch the application from the installation folder by clicking on the exe file or create the shortcuts by themselves.

I also tried to use a batchfile which would look like this:
set _JAVA_OPTIONS=-Duser.home=%temp%
and the next step would be to run the application from that batch file. But then again, you would have to open exactly that batch file otherwise the application could run into troubles again.

the ini file looks like this atm and would be the perfect place to set the desired folder.

-vm
jre_6.0.17\bin\javaw.exe
-vmargs
-Xms64m
-Xmx1024m
-XX:MaxPermSize=256m
-Duser.home=C:\temp

Since the application is running on a terminal server as well I have to use a folder which belongs to the user and he has write privileges in it.
Like %temp% or %userprofile%\foldername
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 39639121
Try (something like) the following in the shortcut

cmd.exe /c java -Duser.home=%temp% Foo

Open in new window


You can of course use javaw.exe instead and change the flag to cmd.exe if you need to
0
 

Author Comment

by:ABX-CEE
ID: 39641210
According to this thread I created a user environment variable through gpp and fixed the java bug with it.

http://www.timehat.com/javas-user-home-is-wrong-on-windows/

Thank you CEHJ for your effort. You helped me solve this.
0
 

Author Comment

by:ABX-CEE
ID: 39641348
I've requested that this question be closed as follows:

Accepted answer: 0 points for ABX-CEE's comment #a39641210
Assisted answer: 250 points for CEHJ's comment #a39639121

for the following reason:

took me some time to realize that its a known java bug, maybe what I did or what I found on the other thread helps others
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39641334
I think there's a little confusion there. The citations are dealing with determining the locations of user.home in Windows, which is problematic. Your requirement was:

Now this is working just fine, but we struggle to set the directory to another userspecific folder like %temp%.

which is a different thing. I just tested, using http://technojeeves.com/joomla/index.php/free/54-javasystemproperties the method i mentioned earlier and had no problem at all setting user.home to %TMP% and the output showed me i had that as the home directory
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39641368
:)
0
 

Author Comment

by:ABX-CEE
ID: 39641373
Sorry about the confusion.
My aim was to find a solution which would work all the time and not only if you click the right shortcut. But I did not mention that in the initial post. I thought this would be easier and java would have the ability to resolve variables set in the config file of the application.

During my research I found that java does not resolve the profile folder correctly (it uses the path of the desktop folder and goes one level up) which in our case is the network user home.

With the user environment variable this is fixed for the mentioned java application and all which would follow, that's why I didn't go with the shortcut solution.
So with the working environment set to:
-Duser.home=%HOMEDRIVE%%HOMEPATH% (C:\Users\Testuser) the path again is user specific (like %temp% no other standard users have access and its not shared with different sessions)


There is also a language barrier which prevents me from making myself fully understandable, I will try to ask more specific next time. Thanks

Cheers
Ben
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

770 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