the_D
the_D

Reputation: 930

Run two tomcats on same machine with different JAVA path

I have two applications, both needs to communicate with each other. App1 is java 8 app and App2 is java 6 app , both are web apps and App1 makes rest calls to App2. I want to simulate this on my local machine but not sure how to create separate localhosts for both the apps.

Please let me know if it is possible or not and if possible please help me in achieving this.

PS: I have installed both java 8 and java 6 on my system and using jenv to switch between java version.

Upvotes: 2

Views: 858

Answers (1)

chengpohi
chengpohi

Reputation: 14217

Yes, it's possible, you can create setenv.sh or setenv.bat under $CATALINA_BASE/bin/ directory. and set the env in setenv.sh or setenv.bat.

when start tomcat, if there is setenv script, it will load this and execute.

catalina.sh

 # Ensure that any user defined CLASSPATH variables are not used on startup,
 # but allow them to be specified in setenv.sh, in rare case when it is needed.
 if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then
  . "$CATALINA_BASE/bin/setenv.sh"
 elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
  . "$CATALINA_HOME/bin/setenv.sh"
 fi

In Linux(setenv.sh), maybe it like:

export JAVA_HOME=my_java_version_home

In Windows(setenv.bat), maybe it like:

set JAVA_HOME=my_java_version_home

Upvotes: 2

Related Questions