• Register
0 votes

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

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 14 views
1 vote
1 answer 411 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 132 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
0 votes
1 answer 7 views
for x in {a..z}; do for y in $x*;do if [ "$y" != "$x*" ]; then let "count++" Can any one help me on what that 2nd for loop does?
asked Sep 15, 2020 Marivoke 530 points
0 votes
1 answer 60 views
I'm a newbie when it comes to Linux administration using bash... I was following a tutorial on how to install laravel 5.2 from here... installed it successfully... firstly I installed composer and ran the following command composer global require "laravel/installer" after this put ... the path Note: I have installed oh my zsh on my terminal... What do I have to do to get it working please help
asked Sep 13, 2020 Marivoke 530 points
1 vote
1 answer 15 views
Problem: Hello Kodlogs, I am a Linux user and currently running Ubuntu 18.04 LTS distribution on my machine. I&rsquo;ve written a sample python program and trying to execute it through the Linux terminal. My sample program is saved as samle.py and I put a command ... command not found Why this is happening? Could you please give a hint? How could I overcome the error? Thanks for enlightening me.
asked Aug 1, 2020 adamSw 11.3k points
1 vote
1 answer 45 views
Problem : I am very new to Linux and currently trying to learn Linux. I want to login to my elementaryOS but I am stuck in the loop I simply tried to enter my password and after that I tried to press enter and I was back to login again. I also tried to enter my ... after spending lot of time and efforts on it still unable to fix it so now I am looking for the Linux experts help to fix above error.
asked May 1, 2020 stewart 4k points
0 votes
1 answer 2.3K views
Problem : Facing following strange issue input is a void element tag and must neither have `children` nor use `dangerouslysetinnerhtml`.
asked Nov 13, 2019 peterlaw 6.9k points
1 vote
2 answers 637 views
Problem : I am using the VirtualBox with OS X as host and CentOS on a guest VM. In OS X I created the folder myfolder, added it as a shared folder to a VM, turned on a VM, in CentOS created folder as /home/user/myfolder and typing as below : sudo ... /user/myfolder But have below output: /sbin/mount.vboxsf: mounting failed with the error: No such device What am I doing wrong in above scenario?
asked Jan 22, 2020 jwilliam 3.9k points