I've edited my .bashrc
file on my server, with sudo nano ~/.bashrc
export JAVA_HOME=/usr/bin/java
export PATH=${PATH}:${JAVA_HOME}/bin
I've re-logged in, and here is all the path as output:
root@ubuntu-s-1vcpu-1gb-blr1-01:~/maifee/backend-spring# echo $JAVA_HOME
/usr/bin/java
root@ubuntu-s-1vcpu-1gb-blr1-01:~/maifee/backend-spring# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/bin/java/bin
But when I try to run my spring boot server, it gives me:
root@ubuntu-s-1vcpu-1gb-blr1-01:~/maifee/backend-spring# ./mvnw spring-boot:run
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/bin/java/bin/java
And when I try to do a mvn install
, I get:
root@ubuntu-s-1vcpu-1gb-blr1-01:~/maifee/backend-spring# mvn install
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
But here is the java configuration list:
root@ubuntu-s-1vcpu-1gb-blr1-01:~/maifee/backend-spring# sudo update-alternatives --list java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
And when I try to run(just tried, without installing dependencies), I get:
root@ubuntu-s-1vcpu-1gb-blr1-01:~/maifee/backend-spring# ./mvnw spring-boot:run
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/bin/java/bin/java
How can I set up my environment to correctly, run my Spring Boot server? I directly have source code there, I don't even need compiling and stuffs.