My application.conf uses environment variables like this
cassandraUri = ${?DB_CASSANDRA_URI}
I am starting my Play application using the .bat file created by sbt dist. I have specified the value of DB_CASSANDRA_URI both in the .bat file and also in cmd.
set "PSK"="mysecret"
set "ALLOWED_NODES"="localhost"
set "DB_CASSANDRA_URI"="localhost"
set "DB_CASSANDRA_PORT"="9042"
set "DB_KEYSPACE_NAME"="ksname"
set "DB_USERNAME"="cassandra"
set "DB_PASSWORD"="cassandra"
set "EMAIL_SERVER"=""
set "EMAIL_USER"=""
set "EMAIL_PASSWORD"=""
set "MOCK_EMAIL"="true"
But the application still can't read the variables.
Am I setting the variables incorrectly? What is the right way?
A way to run multiple programs in a bat file.
Objective
Distribute a software with GDAL as a dependency.
To do that I have downloaded gdal binaries from GIS Internals. The downloaded data has a .bat file to set environment variables. It uses set command to set the environment variables.
As per my limited knowledge in windows bash scripting, I understand that the environment variables set by set are limited to current command prompt itself and are reset when a new command prompt is launched.
Also, is it true that a calling a batch file from a batch file launches new command prompt which when closes doesn't affect the next command called in the parent script.
There is another issue here - will the environment variables affect the process created (such as calling gdal_translate) by a Java program? If it doesn't, then there is no point in setting local environment variable.
Final Requirement:
How to use the environment variables set in another batch file (called from a batch file) in the next line of the parent batch file, without using setx?
If you use the CALL command to run the batch file as specified in the accepted answer on the question you linked to, then the environment variables will pass up to the parent batch file.
There are three times where this is not true:
When using SETX neither the parent nor child batch file will get the environment variables.
When using SETLOCAL and ENDLOCAL inside the child batch file the parent batch file will not get the environment variables.
When running the child batch file using start or cmd.exe /c.
So long as you run your Java application in the same environment (i.e. the same batch file), it will pick up the same environment variables. You can verify this with an application like Process Explorer.
Running set _kjhgkjshdgkjhdfg=TEST before running a .jar file resulted in the screenshot below using any of:
javaw -jar jarfile.jar
cmd /c javaw -jar jarfile.jar
start cmd /c javaw -jar jarfile.jar
C:\apache-jmeter-4.0\bin>jmeter.bat
The JMETER_HOME environment variable is not defined correctly
This environment variable is needed to run this program
JMETER_HOME is set correctly in environment variable.
ApacheJMeter.jar is working fine.
Similar issue found in below link but this also not helping me.
JMETER_HOME environment variable is not defined
You don't need to set JMETER_HOME variable manually, jmeter.bat script should detect it automatically.
Just in case you want to override it for any reason make sure you do this carefully and the variable points to your JMeter installation like:
set JMETER_HOME=C:\apache-jmeter-4.0 pushd %JMETER_HOME% && jmeter.bat
It might also be the case that Windows doesn't have necessary permissions assuming JMeter lives in root of system drive, try running command prompt as Administrator
More information:
Running JMeter
How to Get Started With JMeter: Part 1 - Installation & Test Plans
You don't need to set JMETER_HOME path explicitly under user variables, just add/change under system variables under path variable as your bin path. If you already have earlier version of JMeter just append with latest version. Path looks like : C:\XXX\apache-jmeter-4.0\bin
I am facing this problem :
the CATLALINA_HOME environment variable contains this value:
"?C:\Tomcat" instead of "C:\Tomcat".
I don't know where this "?" comes from.
I am working on Windows.
thanks
Usually that variable comes from catalina.sh or catalina.bat look for this files in your Tomcat/bibn folder.
If you're working on Windows just open the file .bat: catalina.bat
I downloaded apache-tomcat-7.0.40 for Windows 8 and I followed the instructions by using the C:\apache-tomcat-7.0.40> startup.bat at my command prompt. The tomcat application appeared for 1 second and then disappeared, so I maybe the documents installation is not enough?
What should I do? While my local host is internet information service.
In command prompt run below command, you will get the root cause.
...\apache-tomcat-7.0.42\bin> catalina.bat run
In my case it was because I run catalina.bat start and this command creates new command prompt, while catalina.bat run executes in the same command prompt and doesn't close it after finishing.
Try to remove the slash at the end of CATALINA_HOME variable path.
Catalina needs JAVA_HOME to work properly. So configure path to java jre and JAVA_HOME in environment variables.
To see the error, in command prompt execute
\path\apache-tomcat-6.0.41\bin > catalina.bat run
Go to your tomcat/bin folder. Edit startup.bat file, comment out last but one line which says:
call "%EXECUTABLE%" run >..\logs\OutputFile.log 2>&1 start %CMD_LINE_ARGS% run >..\logs\OutputFile.log 2>&1
comment out using 'rem' beginning of it.
rem call "%EXECUTABLE%" run >..\logs\OutputFile.log 2>&1 start %CMD_LINE_ARGS% run >..\logs\OutputFile.log 2>&1
then Console will be remain open. if this line is commented then that means it says to close the console and write the output in some external log file.
Your problem is, most likely, wrong path of the CATALINA_HOME environment variable.
Answers above would help, but I will add one point, which would be more extensive as it may help for different kind of exceptions connected to server startup, and namely - to CATALINA_HOME.
In the late versions of Tomcat, You actually do not need to set environment variable CATALINA_HOME. If you'll have a look inside start startup.bat, the script sets it itself upon each execution.
[23-30] lines of the script in Tomcat 9:
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME=%cd%"
cd "%CURRENT_DIR%"
So, just to be safe that your environment variable doesn't mess up with something defined by Tomcat script startup.bat (or anything else), you can either:
Remove your CATALINA_HOME environment variable entirely, as long as you start your server with startup.bat;
Correct your environment variable CATALINA_HOME path if you insist to be starting it otherwise, and make sure, nothing overrides it during run-time.