Win a copy of Fixing your Scrum this week in the Agile forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Different java version for each web app

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to have one web application running on Java version A and another web application (installed on the same server) running on Java version B?

If so, how to do that?
 
Master Rancher
Posts: 3999
52
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, let's say you want to run your web apps using Tomcat.  You could install two different tomcat instances on your server, using different ports and different Java versions.  Then each webapp could run in a different Java version and different tomcat environment, on the same server (i.e. the same machine).  You can't run two different Java versions in the same Tomcat instance - because Tomcat itself is a Java app, and shares its own JVM with whatever webapps it is running.  

In general though, the preferred solution is probably to take whatever webapp is using a lower version of Java, and upgrade it to use the higher version, so the two apps can share the same version.  If you can't, that's a sign that you're dependent on technology that is not being well-maintained.
 
Jf Okeeffe
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the answer.
How to do this tomcat port configuration for each one to point to a different java version?

And would you know how to do the same on jboss/wildfly?
 
Marshal
Posts: 26745
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems like you're asking how to configure the listening port for an instance of Tomcat. Here's one of the tutorials I found online which tell you that: Modify the default Apache Tomcat port. And you also want to know how to specify the Java version it uses? 4 Ways to Change JRE for Tomcat.

Naturally you would need to install those different Java versions on the server.
 
Jf Okeeffe
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Paul.
 
Saloon Keeper
Posts: 24171
165
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
Just to recap here. Every Tomcat server instance runs as a stand-alone JVM instance. And since Java allows multiple JVMs to be installed and running on any OS, that means that you can therefore run multiple Tomcats, each under a different (or the same) JVM version.

TCP/IP, on the other hand allows one and only one application to own a specific TCP/IP port. So you have to assign unique ports to each Tomcat instance. Note that Tomcat actually listens on 4 or 5 ports - the HTTP port (8080), the HTTPS port (8443), the control port (8005) and the AJP port (8009). For Tomcat to operate properly, all 4 ports should be mapped uniquely to each Tomcat instance. Actually, Tomcat will run even if all 4 ports are unavailable, but since it cannot listen to an unavailable port, it will have limited capabilities.

You may think that Tomcat is a monolithic program, but actually, it's more like a set of JavaBeans strung together. The Tomcat server.xml defines and configures those beans and their relationships. A Connector bean, for example, defines a Tomcat listener port, so it's the Connector elements that yuu have to change to run multiple Tomcats.

Now, having said all that, please remember that Java is almost 100% backwards-compatible between releases. So If you have a mix of webapps, some built for Java 8 and some built for Java 11, a single Tomcat running under Java 11 will generally be able to run all of them. Most of the exceptions involve stuff that probably shouldn't be in your webapps anyway. Note that the Java class compatibility parameter does apply to the entire JVM, so you cannot specifically indicate the release of Java that a given webapp deployment will run under, but as long as there are no backwards compatibility issues, just running Tomcat under the greatest common denominator version will do.

And yes, I think that just about any of the other popular webapp servers support alternate listening port assignments as well. And if they don't - spin up a VM or container instance with port remapping.
 
Jf Okeeffe
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great. Thank you Tim.
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic