
My Java ExceptionUtil Class
September 16, 2019
How To Use CKEditor 5 In Angular With Server Side Rendering Support
September 28, 2019
This week I did research on environment variables in Java on a Windows system. Let me create a scenario for you: we are creating a Java program where a file is uploaded and then is saved some where on your personal computers directory (somewhere being a specific place you would like to save it to).
In order to do this you need to use environment variables so that users can change where they would like the file to be saved.
In your java program you will use the line of code:
System.getenv("DIRECTORY");
- Where DIRECTORY is the name of your system variable.
- This will give you the file location for the file to be saved to.
Now you need to create an environment variable with the same variable name you used in the previous code snippet.
In order to create a new system variable follow these steps:
- Run your command prompt as Administrator
- Create a env.bat file
- In the file type:
set Variable "C:\%USER%\Value" -m
- Where:
- Variable is the name of your new environment variable,
- %USER% gets the user environment variable.
- Value is the rest of the file directory that you would like this new environment to save to.
- Where:
- Save the env.bat file
- In your command prompt run the env.batch file by typing env
- Your environment variable is now created.