Home > Back-end >  How to resolve Error: JAVA_HOME is not defined correctly
How to resolve Error: JAVA_HOME is not defined correctly

Time:12-13

I have a wso2 identity server and I am trying to restart it on putty, however when I navigate into the bin folder by typing the command cd /usr/lib64/wso2/wso2is/5.11.0/bin and then type sh wso2server.sh to start the server I get the following error:

Error: JAVA_HOME is not defined correctly. CARBON cannot execute /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/bin/java

My error logs also say " Halting JVM "

Previously when starting the server it would run and the moment I closed putty the url would no longer work, now however I am somehow getting a JAVA-HOME error and I am unsure about what I did to cause this.

How would I be able to resolve this error? Any assistance would be greatly appreciated.

CodePudding user response:

The error message suggests that the JAVA_HOME environment variable is not set correctly on your system. The JAVA_HOME variable should be set to the path of your Java installation. You can set the JAVA_HOME variable by following these steps:

Open the .bashrc file in a text editor. This file is typically located in your home directory. For example, if your username is user, you can open the file by running the following command:

nano ~/.bashrc

Add the following line to the file, replacing /path/to/java with the path of your Java installation:

export JAVA_HOME=/path/to/java Save the file and exit the text editor.

Run the following command to apply the changes:

source ~/.bashrc

After setting the JAVA_HOME variable, try starting the server again and see if the error persists.

CodePudding user response:

First verify whether your JAVA_HOME is correct. It seems although the path is set to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64 the Java executable is not present. To verify you can do echo $JAVA_HOME abd check the content in the directory. If it's not properly set check this document and set it properly.

Also, if you want to keep the server running when you close the Putty session. Start the server with the below command, which will start it as a background process.

sh wso2server.sh start
  • Related