Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear instructions on how to add Java_Home to Linux startup script #69

Open
jimothyclark opened this issue Aug 2, 2018 · 1 comment

Comments

@jimothyclark
Copy link

I am VERY new to all of this, but I am humble enough to admit that I am a novice and I am coachable enough to learn from anyone! I have researched a couple best practices to avoid stepping on anyone's toes, but I am happy to learn ways my use of this site could improve.

I am learning Linux and I am trying to do configure Java_Home on my Linux. So far, I have barely done more than install a few virtual machines (CentOS 7 and two clones; CentOS7 Full DVD and CentOS 7 NetInstall).
My Jenkins course on stackskills.com referred me to GitHub with my questions and I'm having trouble with the following instructions on how to add Java_Home to my startup script:

Configure Java_Home on Linux:
Login to your account and open the startup script file which is usually ~/.bash_profile file (or can be .bashrc depending on your envrionment settings)
$ vi ~/.bash_profile

In the startup script, set JAVA_HOME and PATH

C shell:

setenv JAVA_HOME jdk-install-dir
setenv PATH $JAVA_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH
jdk-install-dir is the JDK installation director, which should be something similar to /usr/java/jdk1.5.0_07/bin/java

Bourne shell:

JAVA_HOME=jdk-install-dir
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
Korn and bash shells:

export JAVA_HOME=jdk-install-dir
export PATH=$JAVA_HOME/bin:$PATH
Type the following command to activate the new path settings immediately:

$ source ~/.bash_profile

Verify new settings:

$ echo $JAVA_HOME

$ echo $PATH

I'm not exactly sure how to use these instructions. Below is a screenshot of my VM and, from the formatting, it looks like I have the Bourne shell.

Please advise...

linux screenshot startup script help virtualbox_centos 7 netinstall_02_08_2018_13_44_28

@Vishal31122000
Copy link

Vishal31122000 commented Mar 14, 2024

Also you can use this if running on ubuntu and setting up the directory for maven. (check your respective version of jdk)

~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi

Set JAVA_HOME to the desired Java installation directory

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

Append Java bin directory to PATH

PATH=$PATH:$JAVA_HOME/bin

export PATH JAVA_HOME
M2_HOME=/usr/share/maven
M2=$M2_HOME/bin
PATH=$PATH:$M2_HOME:$M2

mesg n 2> /dev/null || true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants