The JAVA_HOME environs variable points to the JDK installation directory together with used past times many Java tools together with applications similar Eclipse, Maven, ANT, Tomcat etc. to figure out Java executables every bit they demand Java for running. Unfortunately, When you lot install Java on Linux or Windows, this environs variable is non laid automatically. You demand to do it yourself. Java developers similar me ever laid useful environs variables similar JAVA_HOME, PATH, together with CLASSPATH on the login scripts executed past times the rhythm out when you lot log inwards to Linux e.g. bash_profile.sh, but you lot tin sack also laid JAVA_HOME into /etc/profile for all users. I'll present you lot steps how to detect the place of Java together with how to setup the JAVA_HOME inwards Linux inwards this article together with these steps should also piece of work amongst whatever Linux or Java version e.g. Ubuntu, RedHat, CentOS, SUSE, ArchLinux, Debian, Fedora etc.
where options include:
-d32 piece of work a 32-bit information model if available
-d64 piece of work a 64-bit information model if available
-server to pick out the "server" VM
It agency Java is installed together with added to your PATH, thence one-half of the project is done already. All you lot demand to is detect the place of JDK, which you lot tin sack detect either past times printing PATH every bit follows
or
You tin sack encounter that JDK is installed on "/usr/sun/jdk/v1.6.0_16-64bit".
2) Add the next delineate of piece of work of your .bash_profile file if you lot desire to laid JAVA_HOME for yourself or /etc/profile if you lot desire to laid JAVA_HOME for all user
or
That's it you lot are done. Though don't forget to opened upwards to a greater extent than or less other rhythm out window past times typing bash, csh, or ksh. The novel environs variable volition non endure added to existing shell, you lot demand to opened upwards a novel rhythm out window.
Also, if you lot piece of work bash rhythm out than adding into /.bash_profile brand sense, if you lot piece of work csh (C shell) thence add together JAVA_HOME into /.csh_profile together with similarly for ksh (K shell) add together JAVA_HOME into /.ksh_profile.
They are hidden files inwards your habitation directory inwards Linux, that's why they had prefix dot (.) inwards their name. You tin sack piece of work "ls - alrt" ascendancy to encounter them.
Here is a sample /etc/profile file amongst JAVA_HOME and PATH variable defined for your reference:
By the way, if you lot don't encounter Java installed on your machine, thence download the Linux version of Java from Oracle's website together with install it. Once you lot are done amongst installation simply detect the folder where JDK is installed together with follow the steps given inwards a higher house to laid JAVA_HOME for your Linux environment.
For Application, JAVA_HOME is by together with large referred on start script. It's bad practise to refer difficult coded path of Java installation inwards scripts, you lot volition never detect Tomcat, Maven, Eclipse, NetBeans or IntelliJ doing that because thence when you lot update to a novel Java version they won't endure able to piece of work it until you lot modify their start script. Using JAVA_HOME makes it slow to switch to a dissimilar or novel Java version. See Core Java for the Impatient to acquire to a greater extent than nearly basic concepts of nub Java.
1) It's slow to upgrade JDK without affecting your application startup together with config file which points to JAVA_HOME. you lot simply demand to download a novel version together with brand certain your JAVA_HOME points to the novel version of Java. This is the best do goodness of using an environs variable or links.
2) The JAVA_HOME variable is curt together with concise instead of the sum path to JDK installation directory.
3) JAVA_HOME variable helps your computer programme accomplish platform independence i.e. if your startup script uses JAVA_HOME thence it tin sack run on Windows together with UNIX without whatever modification, you lot simply demand to laid JAVA_HOME on the respective operating system.
4) The JAVA_HOME is standard, which agency other tools which demand Java e.g. Maven, Eclipse tin sack refer this variable without having whatever cognition of where Java is physically installed on your machine, which is apparently dissimilar inwards dissimilar user's machine. JAVA_HOME allows everybody to access Java inwards a mutual together with measure way.
I also advise reading Core Java Volume 1 - Fundamentals past times Cay S. Horstmann to acquire to a greater extent than nearly Java fundamentals similar this one.
That's all nearly how to laid JAVA_HOME environs variable inwards Linux. I accept also touched base of operations on why you lot should do it. If you lot aspect upwards whatever work land setting together with using the JAVA_HOME environs variable, experience costless to ask. I'll endure glad to assist you lot out.
Further Learning
Linux Command Line Interface (CLI) Fundamentals
Linux System Administration Fundamentals
Java Fundamentals: The Java Language
Other Java basics tutorials for Programmers
Steps to laid JAVA_HOME inwards Linux
1) The commencement measurement is to detect the place where Java is installed on your Linux machine. To banking concern tally that opened upwards putty together with connect to your Linux server together with type the next command$ coffee Usage: coffee [-options] course of written report [args...] (to execute a class) or coffee [-options] -jar jarfile [args...] (to execute a jounce file)
where options include:
-d32 piece of work a 32-bit information model if available
-d64 piece of work a 64-bit information model if available
-server to pick out the "server" VM
It agency Java is installed together with added to your PATH, thence one-half of the project is done already. All you lot demand to is detect the place of JDK, which you lot tin sack detect either past times printing PATH every bit follows
$ echo $PATH /usr/local/bin:/bin:/usr/bin:/usr/sun/jdk/v1.6.0_16-64bit/bin:.
or
$ which coffee usr/sun/jdk/v1.6.0_16-64bit
You tin sack encounter that JDK is installed on "/usr/sun/jdk/v1.6.0_16-64bit".
2) Add the next delineate of piece of work of your .bash_profile file if you lot desire to laid JAVA_HOME for yourself or /etc/profile if you lot desire to laid JAVA_HOME for all user
vim /bash_profile export JAVA_HOME=/usr/sun/jdk/v1.6.0_16-64bit/ export PATH = $JAVA_HOME/bin:$PATH
or
vim /etc/profile export JAVA_HOME=/usr/sun/jdk/v1.6.0_16-64bit/ export PATH = $JAVA_HOME/bin:$PATH
That's it you lot are done. Though don't forget to opened upwards to a greater extent than or less other rhythm out window past times typing bash, csh, or ksh. The novel environs variable volition non endure added to existing shell, you lot demand to opened upwards a novel rhythm out window.
Also, if you lot piece of work bash rhythm out than adding into /.bash_profile brand sense, if you lot piece of work csh (C shell) thence add together JAVA_HOME into /.csh_profile together with similarly for ksh (K shell) add together JAVA_HOME into /.ksh_profile.
They are hidden files inwards your habitation directory inwards Linux, that's why they had prefix dot (.) inwards their name. You tin sack piece of work "ls - alrt" ascendancy to encounter them.
Here is a sample /etc/profile file amongst JAVA_HOME and PATH variable defined for your reference:
By the way, if you lot don't encounter Java installed on your machine, thence download the Linux version of Java from Oracle's website together with install it. Once you lot are done amongst installation simply detect the folder where JDK is installed together with follow the steps given inwards a higher house to laid JAVA_HOME for your Linux environment.
For Application, JAVA_HOME is by together with large referred on start script. It's bad practise to refer difficult coded path of Java installation inwards scripts, you lot volition never detect Tomcat, Maven, Eclipse, NetBeans or IntelliJ doing that because thence when you lot update to a novel Java version they won't endure able to piece of work it until you lot modify their start script. Using JAVA_HOME makes it slow to switch to a dissimilar or novel Java version. See Core Java for the Impatient to acquire to a greater extent than nearly basic concepts of nub Java.
Why should you lot laid JAVA_HOME inwards Linux
Even though many developers knows nearly JAVA_HOME they don't laid inwards their environs due to diverse reasons. I strongly recommend you lot to laid JAVA_HOME, PATH, together with CLASSPATH for your evolution environment. Here are to a greater extent than or less reasons why you lot laid JAVA_HOME inwards Linux1) It's slow to upgrade JDK without affecting your application startup together with config file which points to JAVA_HOME. you lot simply demand to download a novel version together with brand certain your JAVA_HOME points to the novel version of Java. This is the best do goodness of using an environs variable or links.
2) The JAVA_HOME variable is curt together with concise instead of the sum path to JDK installation directory.
3) JAVA_HOME variable helps your computer programme accomplish platform independence i.e. if your startup script uses JAVA_HOME thence it tin sack run on Windows together with UNIX without whatever modification, you lot simply demand to laid JAVA_HOME on the respective operating system.
4) The JAVA_HOME is standard, which agency other tools which demand Java e.g. Maven, Eclipse tin sack refer this variable without having whatever cognition of where Java is physically installed on your machine, which is apparently dissimilar inwards dissimilar user's machine. JAVA_HOME allows everybody to access Java inwards a mutual together with measure way.
I also advise reading Core Java Volume 1 - Fundamentals past times Cay S. Horstmann to acquire to a greater extent than nearly Java fundamentals similar this one.
That's all nearly how to laid JAVA_HOME environs variable inwards Linux. I accept also touched base of operations on why you lot should do it. If you lot aspect upwards whatever work land setting together with using the JAVA_HOME environs variable, experience costless to ask. I'll endure glad to assist you lot out.
Further Learning
Linux Command Line Interface (CLI) Fundamentals
Linux System Administration Fundamentals
Java Fundamentals: The Java Language
Other Java basics tutorials for Programmers
- What is the departure betwixt PATH together with CLASSPATH inwards Java? (answer)
- What is the java.library.path arrangement holding inwards Java? (answer)
- How to run Java computer programme from the ascendancy line? (guide)
- How to install JDK vii on Windows 8? (guide)
- Explanation of HelloWorld Program inwards Java? (read here)
- Core Java Volume 1 - Fundamentals past times Cay S. Horstmann (see here)



0 Response to "How to ready JAVA_HOME in addition to PATH inwards Linux"
Posting Komentar