Reputation: 3028
I'm not sure if it is best practice but I add MySQL-connector jar to the extensions directory of my Java install directory to I can easily connect to MySQL databases.
I also set environment variables to point to various directories so that I can develop on different machines and only define environment variables locally and code doesn't have to be modified for file paths.
In either case of the above I find that unless I reboot my computer java does not recogise either. What happens during a reboot to Java? Is some config file updates by a java process? Can you update this without having to reboot?
To test this I have created a new environment variable on both Mac (adding to .MacOS/environment.plist
), Linux (Ubuntu 12.04) and windows 7 (via control panel). I then used System.getenv("TestVar");
which returns null. Running set
from the command line shows it exists though. After a reboot System.getenv("TestVar");
returns the expected value.
Upvotes: 0
Views: 1890
Reputation: 3028
As far as setting environment variables goes the on Ubuntu a log out is required
https://superuser.com/questions/339617/how-to-reload-etc-environment-without-rebooting
Upvotes: 2
Reputation: 7899
Ultimately your goal is to include jar files in CLASSPATH
. its up to you how include jars
in classpath but this is not good practice to put jars inside extensions
directory . While running your program modify CLASSPATH
value .
java -cp jar1:jar2:jar3:dir1:. HelloWorld
java -classpathjar1:jar2:jar3:dir1:. HelloWorld
Upvotes: 2