How (where?) can I set Environment Variables using IntelliJ idea?
For instance, I am looking forward to set the $APP_HOME (my tests rely on).
Where can this be done please?
Most run configurations have an option to set environment variables:
The build settings window has a configuration tab with an option to change the environment variables.
http://www.jetbrains.com/idea/webhelp/run-debug-configuration-application.html
Otherwise you can use system system calls or the java language itself to change them during runtime.
How do I set environment variables from Java?
Related
I have "Development" set in my web.config, in the launchSettings.json (all profiles), and in the environment variables on Windows, but the application still shows the environment as "Staging". Also, even if I run Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") in something like RoslynPad, it also shows "Staging". I do not know where else I can look to set this value. Thank you.
The Environment Context is still "Staging".
As Rena suggested, restarting VS helped fix the issue, and ensuring I did a clean and removing any/all environment variables defined on the OS now allows me to change the environment using the web.config.
Using intelliJ 15 Ultimate on MAC Yosemite.
I have two Jboss installation, jboss-eap-6.4 and wildfly-10.1.0.Final.
Depending on what project I am working on I need the "Run/Debug Configuration" to choose the correct JBOSS_HOME.
My bash_profile :
export JBOSS_HOME=/usr/local/jboss-eap-6.4
I also added convenience way to change in the terminal
alias setEAP='JBOSS_HOME=/usr/local/jboss-eap-6.4'
alias setWILDFLY='export JBOSS_HOME=/usr/local/wildfly-10.1.0.Final'
In Intellij I have :
Every time I run one of the Run/Debug it chooses the JBOSS_HOME set in bash_profile.
/usr/local/wildfly-10.1.0.Final/bin/standalone.sh
WARNING: JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.
JBOSS_HOME: /usr/local/jboss-eap-6.4
I tried to create an External Tool where I export JBOSS_HOME, but this does not work. Anyway I can switch between JBOSS installation ? This could also be applicable to JAVA_HOME
You do not need to create scripts, just go to the Startup/Connection tab and add the value to the list of environment variables.
I have a simple Java application using Gradle as the build tool. Normally when I run my application using gralde I set a specific environment variable set MYVAR=myval and later my application uses this value. When I set up a configuration to Run/Debug my Gradle based application in IntelliJ all goes well except that I have no way that I can find to specify my environment variable MYVAR and thus it is always unset.
I've been reading up on my options in various documents and articles for over two hours now and have gotten nowhere.
I set up an environment variable (Under IDE Settings -> Path Variables)
APP_HOME = /path/to/app_home
One of my tests is failing however with
System.out.println("APP HOME: " + APP_HOME);
With
APP HOME: null/
It does not look like that env variable is being read. What am i missing?
Path Variables dialog has nothing to do with the environment variables.
Environment variables can be specified in your OS or customized in the Run configuration:
I could not get environment variables to work when IntelliJ Build and run property was using Gradle. I am not sure what the root cause is, but switching to IntelliJ IDEA solved the problem. Go to Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle. Then change Build and run using: to IntelliJ IDEA.
If the above answer + restarting the IDE didn't do, try restarting "Jetbrains Toolbox" if you use it, this did it for me
It is possible to reference an intellij 'Path Variable' in an intellij 'Run Configuration'.
In 'Path Variables' create a variable for example ANALYTICS_VERSION.
In a 'Run Configuration' under 'Environment Variables' add for example the following:
ANALYTICS_LOAD_LOCATION=$MAVEN_REPOSITORY$\com\my\company\analytics\$ANALYTICS_VERSION$\bin
To answer the original question you would need to add an APP_HOME environment variable to your run configuration which references the path variable:
APP_HOME=$APP_HOME$
In order to load .DLLs (under Windows) or .SOs (under Linux) we must use the environment variables PATH (Windows) or LD_LIBRARY_PATH (Linux).
The only way we could find to properly use DLLs and SOs was to define the environment variables before starting Netbeans.
Is there a way to specify those environment variables inside
Netbeans?
Is it possible to specify it inside the project
properties? That way each project could have its own definitions.
is there a way to just append to those environment variables instead of just overriding them?
Background: we are developing a Java program that uses JNI to access native libraries. Those native libraries, in turn, access other dependent native libraries. Because of that, just setting the property "java.library.path" doesn't work, as we need to set the full LD_LIBRARY_PATH (or regular PATH in the case of Windows), too.
Outside Netbeans the application runs fine, because we set the environment variables inside shell scripts.
We don't want to just place the DLLs or SOs in the usual system directories because we don't want to mess up with the operating system installation during development. In addition, we want to have the flexibility to allow any developer to simply get the project from source control (Mercurial) and have all relative paths just working.
There is already a hack on stack overflow to set environment variables programmatically in Java. However, we are looking for less hackish a solution.
You can override Ant script tasks that NetBeans uses in build.xml file (or edit it directly in the full script in nbproject/build-impl.xml, but not recommended).
The java task is used on run target. You can use env parameter to specify environment variables to the process that will run the JVM.