Fix IntelliJ not recognizing path variable
Updated at 1715741678000Description
IntelliJ, especially on Windows, may have an issue recognizing path variables, preventing us from building the program. Let's assume we need to import an environment variable EZYPLATFORM_HOME
like this: <ezyplatform.home>${env.EZYPLATFORM_HOME}</ezyplatform.home>
, pointing to the /{your_path}/ezyplatform
directory (the directory that contains cli.sh
and and cli.bat
files), example: /App/ezyplatform
.
Steps
Step 1. Create Environment Variable
- Use Google to search: add environment variable corresponding to your operating system to create the variable
EZYPLATFORM_HOME=/App/ezyplatform
, you can refer to: Add Environment Variables. - Return to the project and try to build. If it works, you are done; otherwise, proceed to step 2.
Step 2. Create Environment Variable in IntelliJ
- Open IntelliJ settings, navigate to Path Variables, and add the variable
EZYPLATFORM_HOME
, for example:
- Return to the project and try to build. If it works, you are done; otherwise, proceed to step 3.
Step 3. Add Global VM Options for Maven
- Open IntelliJ settings, go to Importing, and add the following to VM options for the importer:
-Denv.EZYPLATFORM_HOME=/App/ezyplatform
For example:
- Also, in Maven settings, go to Runner, and add VM Options:
-Denv.EZYPLATFORM_HOME=/App/ezyplatform
And add Environment variables: EZYPLATFORM_HOME=/App/ezyplatform
For example:
- Return to the project and try to build. If it works, you are done; otherwise, proceed to step 4.
Step 4. Configure on Project Level
- Create a project configuration and add VM Options:
-Denv.EZYPLATFORM_HOME=/App/ezyplatform
And add Environment variables: EZYPLATFORM_HOME=/App/ezyplatform
For example:
- At the same time, in the configuration of the startup class (containing the main method) of the program, you will also need to add VM Options and Environment variables similarly, for example:
- Return to the project and try to build. If it works, you are done; otherwise, further investigation is needed.