• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Tomcat as service.

 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I noticed an interesting thing with Tomcat or I must have missed something silly. So though of discussing it here.

I want to run tomcat 5.5 as service and it should use a specific JRE , not the one which is being pointed by JAVA_HOME environment varialbe.
To run Tomcat as service , there is a batch file named service.bat in the bin directory .With its help you can install/remove tomcat service instances as windows service.

Question is how do I pass it a different JRE then the one which is pointed by the environment variable JAVA_HOME.

I gone through the code of service.bat and found that it tries to identify the JRE and stores it in a variable PR_JVM , but never seem to use it. I can change the code to point PR_JVM to my jre , but how do I pass it to Tomcat5.exe so that it uses it. In the web also I could not find any good documentation about the usage of tomcat5.exe.

I was suppose to write to the tomcat developers and users mailing list , then though of writing to JR before doing so.

Any pointers would greatly be appreciated .

Thanks,
Rahul Bhattacharjee
 
Saloon Keeper
Posts: 28316
207
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat uses JAVA_HOME, but it doesn't have to be the same JAVA_HOME that your default environment sets.

Add a file named "SETENV.BAT" to your Tomcat\bin directory and place a "SET JAVA_HOME=" statement in it.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Tim.

Will your procedure change the JAVA_HOME of the environment itself , or only Tomcat would refer to it while running.
 
Tim Holloway
Saloon Keeper
Posts: 28316
207
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Each process has its own environment unless the process creator was told to share its environment with the created child. So the JAVA_HOME im your Tomcat process won't be the same JAVA_HOME in any of the other processes.

To see this in action, open 2 command windows. In the first window issue the command "SET X=123". In the second window, issue the command "SET X=456".

Now go back to the first window and issue the command "ECHO %X%".
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank a lot Tim , its time to do some reading and make hands dirty !!

Regards,
Rahul Bhattacharjee
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The setenv.bat thing did not work (or I might have done something wrong , didn't get much time to look deeply into it). However , with a little modification to service.bat , I was able to register tomcat as service ,that used my JRE.

Looks to me like the service looks for the PR_JVM variable for JRE , and if this is set to auto , it uses the one configured with the system.

Thanks,
Rahul Bhattacharjee
 
Space pants. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic