Tracy Hiltbrand

Greenhorn
+ Follow
since Feb 21, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tracy Hiltbrand

If it's working in NetBeans, you've probably got the "Working Directory" property set. To check, right click the project in NB, choose Properties, click the "Run" category. I'm betting that the Working Directory property is set to a specific directory. If not, NB would automatically set it to the project directory.

So, either way, when NB runs your JAR file for you, it passes the option "-Duser.dir=PathToWorkingDirectory".

So if you want to produce that same behavior from the command line, just use that option. For example:

java -Duser.dir=PathToWorkingDirectory -jar YourJarFileName.jar

Hope that helps!
10 years ago