my java exceptionutil class

My Java ExceptionUtil Class

September 16, 2019
how to use ckeditor 5 in angular with server side rendering support

How To Use CKEditor 5 In Angular With Server Side Rendering Support

September 28, 2019

System Environment Variables On Windows

September 18, 2019 / Rayne Falkenberg

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:

  1. Run your command prompt as Administrator
  2. Create a env.bat file
  3. 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.
  4. Save the env.bat file
  5. In your command prompt run the env.batch file by typing env
  6. Your environment variable is now created.
Share

Rayne Falkenberg

Rayne is a developer manager with experience in web apps, mobile apps and project management.

✕
System Environment Variables On Windows
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.
Read more