Do I need JRE_HOME? Tomcat java environment version difference - java

Recently I had come across an error while running a basic webapp in tomcat.
The error was "class has been compiled by a more recent version of the Java Environment". I am using jdk-11.0.2 and jre1.8.0_201. Then I came across this page about setting tomcat server which says :
If both JRE_HOME and JAVA_HOME are specified, JRE_HOME is used
So I tried deleting the JRE_HOME variable and that solved the error.
Is this the right method to solve the issue? Is it possible to make JRE_HOME invisible for tomcat alone? Am I going to need JRE_HOME anywhere else?

So I tried deleting the JRE_HOME variable and that solved the error.
Is this the right method to solve the issue?
Yes. Based on your information , your web app requires Java version >8 to run. And what you do here is to ensure that Tomcat is using Java 11 to run which is the right direction to solve the problem.
Also , it is very normal that you only set JAVA_HOME but not set JRE_HOME because behind the scenes if you do not set JRE_HOME , Tomcat startup script (setclasspath.bat) will automatically set JRE_HOME for you based on the JAVA_HOME value.
You can also customize / override JRE_HOME or JAVA_HOME by creating a setenv.sh inside bin folder. All settings inside setenv.sh is only applied for the Tomcat :
export JAVA_HOME=/path/to/jdk-11.0.2

Related

Tomcat won't start even with both JAVA_HOME and JRE_HOME set

I have to install tomEE to run an application I have to modify.
But when I use
\apache-tomcat-7.0.77\bin>start startup.bat
I get the following message :
"Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program"
The problem is I have already set my two variables :
C:\Program Files\Java\jdk1.8.0_102
for JAVA_HOME
and
C:\Program Files\Java\jre1.8.0_102
By the way I already set CATALINA_HOME to me apache folder
All suggestions are welcome :)
Best regards.

Error when starting Liferay 7 (liferay-portal-7.0-ce-ga1): PWC6345: There is an error in invoking javac.A full JDK (not just JRE) is required

I am getting the following error when starting Liferay (liferay-portal-7.0-ce-ga1):
org.apache.jasper.JasperException: PWC6345: There is an error in
invoking javac. A full JDK (not just JRE) is required
I have set my system environment variables correctly:
JAVA_HOME: C:\Program Files\Java\jdk1.7.0_80
JRE_HOME: C:\Program Files\Java\jre7
I have added my JAVA_HOME path to my system Path variable:
....;C:\Program Files\Java\jdk1.7.0_80\bin;
When I run the windows where javac command, I get the following:
C:\Program Files\Java\jdk1.7.0_80\bin\javac.exe
What am I missing?? I have also tried using JDK 1.8 and JDK 1.7.0_79. Same results.
Thanks for your help!
After a lot of trial and error, and a lot of searching and several Windows Environment Setting Changes, I resolved this issue. I will point to the last 2 locations that led me to get over the finish-line because I had done some many things.
1) I made sure my JAVA_HOME pointed to my Java JDK (1.8.0_xx) and my JRE_HOME pointed to my Java JRE (1.8.0_xx)
2) I removed the C:\ProgramData\Oracle\Java\javapath; from my PATH variables (there were 2 PATH variables, removed from both)
3) Made sure my PATH variables (both) at the JDK Bin folder path: C:\Program Files\Java\jdk1.8.0_65\bin;
Then I checked my CMD 'where java' and received the correct response:
C:\Program Files\Java\jdk1.8.0_65\bin\java.exe
4) In Eclipse, under the top menu: Windows > Preferences > Java > Installed JREs
Here, I originally had the jre1.8.0_65, but I added the jdk1.8.0_65 and selected it.
5) Finally, what seemed to make the biggest difference:
Right-Click on your server, and at the bottom, select Properties.
A window will open up, and the 3rd option, there's clickable text "Runtime Environment". Click it and a popup will open, there will be a bottom drop-down under "Select runtime JRE" Here, I selected jdk1.8.0_65
That finally corrected the issue for me. Here are 2 links in reverse order.
http://www.huqiwen.com/2016/05/11/liferay-7-there-is-an-error-in-invoking-javac/
https://web.liferay.com/community/forums/-/message_boards/message/74821940?_19_threadView=tree
In your environment both JRE_HOME and JAVA_HOME are set. In this case Tomcat will prefer the JRE_HOME over the JAVA_HOME. JRE_HOME should point to a JRE while JAVA_HOME should point to a JDK.
You could just delete the JRE_HOME environment variable and Tomcat would automatically switch to JAVA_HOME so the isseue would be solved. If you want to keep the JRE_HOME in Windows you can change the setenv.bat by adding the following line as a first line.
set "JRE_HOME=%JAVA_HOME%"
This change will tell Tomcat that the JRE_HOME should be considered equal to JAVA_HOME and will not change your environmental variables.

How do I update JAVA_HOME / JRE_HOME on Tomcat on Ubuntu 15.04?

I'm trying to set my JRE_HOME variable in catalina.bat to be where my java is stored (/usr/lib/jvm/default-java) in Ubuntu. I edited catalina.bat and added "set JAVA_HOME=/usr/lib/jvm/default-java" at the very top of the file but when I use "./catalina.sh version" it keeps stating "Using JRE_HOME: /usr". How do I setup my catalina.bat file so that the JRE_HOME will update?
I've tried a few older guides for older versions of Ubuntu but nothing has worked. Any and all help is appreciated I just want to get my computer working for java server side programming. Thanks in advance.
When you starting tomcat using catalina.bat, it searching for file setenv.bat and sourcing it. It is searching in CATALINA_HOME or CATALINA_BASE
So the better way to set JAVA_HOME for the tomcat is:
Create setenv.bat script CATALINA_BASE/bin, if it is not exists already.
Add this line to setenv.bat
export JAVA_HOME=/opt/java/jdk1.8.0_05
Make it executable.

not able to get tomcat server running - startup.bat does nothing

when i click on startup.bat , nothng happens.
Here is what I tried - I made sure that i installed the correct version of tomcat, for windows xp 32 bit. yet nothing happens.
I also created the JAVA_HOME and gave it the correct location of my sdk
here is the error i am getting
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
For Tomcat8 a minimum JRE7 is required, please add JRE_HOME in envrionment/system variable
put your tomcat/bin path in your class path and try to start server.

Not able to start Jboss Server on run.bat

I'm getting a ClassNotFoundException when I run the JBoss Server using run.bat.
Updated:
The issue seems to be that your JAVA_HOME environment variable is not set to a JDK. Your screen shot shows a JRE for the JAVA_HOME. Switch that to a JDK and re-try starting JBoss.
Also the JAVA_HOME should be in your PATH environment variable.
Alternatively you can manually set the JAVA_HOME in the run.conf.bat file
your java path is not set to jdk and you have to configure java path in as java_home in standalone.conf.bat
and start with run.bat

Categories