简体   繁体   中英

How to enable java path to be used within linux system startup scripts?

I was trying to create a startup script for Apache Storm, which can automatically start storm supervisor upon boot.

But I constantly get this error:

Traceback (most recent call last):
File "./home/ec2-user/apache-storm-1.1.2/bin/storm.py", line 887, in main()
File "./home/ec2-user/apache-storm-1.1.2/bin/storm.py", line 884, in main (COMMANDS.get(COMMAND, unknown_command))(*ARGS)
File "./home/ec2-user/apache-storm-1.1.2/bin/storm.py", line 679, in supervisor
jvmopts = parse_args(confvalue("supervisor.childopts", cppaths)) + [ File "./home/ec2-user/apache-storm-1.1.2/bin/storm.py", line 153, in confvalue
p = sub.Popen(command, stdout=sub.PIPE)
File "/usr/lib64/python2.7/subprocess.py", line 390, in init errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1025, in _execute_child raise child_exception
OSError: [Errno 2] No such file or directory

It seems to me that the error is caused due to the inability of detecting JAVA_HOME and related java path.

I used this script with modified paths

I already configured javapath in /.bashrc , /etc/profile , /etc/environment . But nothing seems to work.

Can anyone help?

I am happy to declare that I rectified this issue by appending:

export JAVA_HOME=/opt/jdk1.8.0_171
export JRE_HOME=/opt/jdk1.8.0_171/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

to the startup script itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM