Java version for starting an application server

Hi,

I would like to know if it's possible to declare the application server java version when declaring it in run configurations.

Here's is the context :
My intellij is started with java 7.
My webapp only support java 6 because of its dependencies. So I declare it as a java 6 application.
When I run the application, the tomcat is started with java 7 instead of java 6.

Did I miss something ?

Thank you

2 comments
Comment actions Permalink

To start Tomcat, IDEA simple runs Tomcat's startup script in Tomcat's bin directory. The startup script in turns uses the JRE_HOME or JAVA_HOME environment variable to determine what java install to use. (JRE_HOME takes precedence over JAVA_HOME if both are defined.) See section 3.2 of http://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt for more information.

When you run the Tomcat configuration, in the run tool window, in the console output tab, you will see that environment variable that is being used, and its value. For example:

P:\apps\tomcat\7.x\v7.0.11\bin\catalina.bat run
[2012-08-04 02:55:37,601] Artifact my-webapp:war exploded: Server is not connected. Press 'Deploy' to start deployment.
Using CATALINA_BASE:   "P:\data\configs\.IntelliJIdea12\system\tomcat\Unnamed_my_project_3"
Using CATALINA_HOME:   "P:\apps\tomcat\7.x\v7.0.11"
Using CATALINA_TMPDIR: "P:\apps\tomcat\7.x\v7.0.11\temp"
Using JRE_HOME:        "P:\java\1.7-x64"
Using CLASSPATH:       "P:\apps\tomcat\7.x\v7.0.11\bin\bootstrap.jar;P:\apps\tomcat\7.x\v7.0.11\bin\tomcat-juli.jar"


So you need to change one of those environment variables to the appropriate java version. If you do not want to change them system wide, you can modify them for just your Tomcat Run/Debug Configuration instance:

  1. Open the Run/Debug Configuration
  2. Navigate to the "Startup/Connection" tab
  3. Make sure "Pass environment variables" is selected
  4. Add a JAVA_HOME or JRE_HOME environment variable definition with a value to the java install you want to use
  5. Save and run
0
Comment actions Permalink

Hi Mark,

Thank you for your explanation.
In fact, it was what  I was doing but the problem was somewhere else. I use the tomcat bundle from Bonita Open Solution and there is a script to detect java version in the setenv.bat. It seems that this detection does not work well.
I commented this script and tomcat starts with the right version of Java.

Cheers

0

Please sign in to leave a comment.