• Register
0 votes
93 views

Problem :

I am beginner to CentOS. I tried executing sudo ./startup.sh in my CentOS, But I am facing the below error:

"Neither the JAVA_HOME nor the JRE_HOME environment variable is defined"

I have already defined them in my bashrc as shown below:

export JAVA_HOME=/home/mphil/New_learning/jdk1.8.0_212
export PATH=$JAVA_HOME/bin:$PATH

How to fix this error?

8 4 2
2,300 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I can say this is very basic mistake done by most of the beginners.

Please follow below approach to fix the error.

I can tell you one thing when you define them in your .bashrc file, it is really good and well defined for the your user.

But when you launch a command with the use of sudo, then it will run as the super-user/root, and NOT as the your user; so your current .bashrc file is 'useless' in this scenario.

In your case you must update the environment with your system file as shown below under the /etc/profile.d for example:

You need to write below commands very carefully

sudo touch /etc/profile.d/variousPath.sh
sudo chown bsquare /etc/profile.d/variousPath.sh
cat >> /etc/profile.d/variousPath.sh <<EOF
export JAVA_HOME=/home/mphil/New_learning/jdk1.8.0_212
export PATH=$JAVA_HOME/bin:$PATH
EOF

Now you just need to restart your computer, and then your SYSTEM environment will know your $JAVA_HOME.

I hope it fixes your problem

5 2 1
4,980 points

Related questions

0 votes
1 answer 35 views
35 views
Solve this problem.
asked Jan 22 TeamScript 13.5k points
0 votes
1 answer 17 views
17 views
Problem: the jre_home environment variable is not defined correctly.
asked Feb 20 charles mathews 5.5k points
0 votes
1 answer 1 view
1 view
Problem: I'm trying to add a directory to my path so it will always be in my Linux path. How can I do it so this will be set permanently?
asked 2 days ago ummesalma 22.7k points
0 votes
1 answer 5 views
5 views
Problem: whenever I try to use sudo, I get this error - sudo: effective uid is not 0, is sudo installed setuid root? Any help would be appreciated. :)
asked Mar 22 ummesalma 22.7k points
0 votes
0 answers 107 views
1 vote
1 answer 630 views
630 views
Problem: I have fundamental knowledge of MySQL server. My MySQL server is on the CentOS and it has been working as expected but all of a sudden I am unable to restart my mysqld today. If I try to execute below command it shows me failed. # /etc/rc.d/ ... lib/mysql 151129 15:54:37 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended Kindly guide me in fixing above MySQL related error.
asked Jun 1, 2020 Martin K 6.6k points
0 votes
1 answer 16 views
16 views
Problem: The java_home environment variable is not defined correctly.
asked Feb 18 Ethan ross 2.3k points
0 votes
1 answer 57 views
1 vote
1 answer 5 views
5 views
Problem: Any ideas on what I need to do to fix this? java_home environment variable is not defined correctly
asked Mar 26 MUHAMMAD MUNEEB 80k points
0 votes
1 answer 181 views
181 views
Problem : I am very new to Shell scripting. Currently I am trying to write the Shell Script which should create some dirs on my remote server and then it should use the scp to copy the files from the local pc on the remote server. But whenever I try to ... Pseudo-terminal will not be allocated because stdin is not a terminal.&rdquo; And my script hangs after the message. How to fix above message?
asked Feb 24, 2020 mphil 2.3k points