Skip to main content

Managing JAVA

Installing default JRE/JDK

This is the recommended and easiest option. This will install OpenJDK 6 on Ubuntu 12.04 and earlier and on 12.10+ it will install OpenJDK 7.
Installing Java with apt-get is easy. First, update the package index:
sudo apt-get update
Then, check if Java is not already installed:
java -version
If it returns "The program java can be found in the following packages", Java hasn't been installed yet, so execute the following command:
sudo apt-get install default-jre
This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache AntApache MavenEclipseand IntelliJ IDEA execute the following command:
sudo apt-get install default-jdk
That is everything that is needed to install Java.
All other steps are optional and must only be executed when needed.

Installing OpenJDK 7 (optional)

To install OpenJDK 7, execute the following command:
sudo apt-get install openjdk-7-jre 
This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), execute the following command:
sudo apt-get install openjdk-7-jdk

Installing Oracle JDK (optional)

The Oracle JDK is the official JDK; however, it is no longer provided by Oracle as a default installation for Ubuntu.
You can still install it using apt-get. To install any version, first execute the following commands:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Then, depending on the version you want to install, execute one of the following commands:

Oracle JDK 6

This is an old version but still in use.
sudo apt-get install oracle-java6-installer

Oracle JDK 7

This is the latest stable version.
sudo apt-get install oracle-java7-installer

Oracle JDK 8

This is a developer preview, the general release is scheduled for March 2014. This external article about Java 8 may help you to understand what it's all about.
sudo apt-get install oracle-java8-installer

Managing Java (optional)

When there are multiple Java installations on your Droplet, the Java version to use as default can be chosen. To do this, execute the following command:
sudo update-alternatives --config java
It will usually return something like this if you have 2 installations (if you have more, it will of course return more):
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:
You can now choose the number to use as default. This can also be done for the Java compiler (javac):
sudo update-alternatives --config javac
It is the same selection screen as the previous command and should be used in the same way. This command can be executed for all other commands which have different installations. In Java, this includes but is not limited to: keytooljavadoc and jarsigner.

Setting the "JAVA_HOME" environment variable

To set the JAVA_HOME environment variable, which is needed for some programs, first find out the path of your Java installation:
sudo update-alternatives --config java
It returns something like:
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:
The path of the installation is for each:
  1. /usr/lib/jvm/java-7-oracle
  2. /usr/lib/jvm/java-6-openjdk-amd64
  3. /usr/lib/jvm/java-7-oracle
Copy the path from your preferred installation and then edit the file /etc/environment:
sudo nano /etc/environment
In this file, add the following line (replacing YOUR_PATH by the just copied path):
JAVA_HOME="YOUR_PATH"
That should be enough to set the environment variable. Now reload this file:
source /etc/environment
Test it by executing:
echo $JAVA_HOME
If it returns the just set path, the environment variable has been set successfully. If it doesn't, please make sure you followed all steps correctly.


From: https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get

Comments

Popular posts from this blog

Navigating the JOBS in the times of AI

One of last staturdays I spoke to first-year students on the opening day of their year. Eighteen, most of them. Some had come for computer science, some for the humanities, some for management or commerce or the pure sciences. Bright, a little restless, and all of them carrying the same question without quite saying it: now that AI has shown up, what happens to my career? I want to write down what I told them, because I don't think it's a question only eighteen-year-olds are asking. Why do jobs even exist? Strip everything away and a job is just a problem somebody is paid to solve. People need food, health, a roof, education, safety, someone to talk to. Those needs don't go anywhere, and every one of them is somebody's work. What's easy to miss is that the needs stay put while the way we meet them gets rewritten every couple of generations. Farming gave us a food surplus. The steam engine gave us factories. Electricity, mass production. Computers, the information...

आपण महाराष्ट्राच्या संस्कृतीचे अजूनही खरंच पाईक आहोत कि भरकटलोत ?

महाराष्ट्र दिनाच्या सगळ्यांना शुभेच्छा. तसं ज्याला आज आपण महाराष्ट्र म्हणतो, त्याचा हा आधुनिक जन्म दिवस. महाराष्ट्र कधी पासून अस्तित्वात असेल? म्हणजे इथली संस्कृती, आपण जे वागतो, जगतो, बोलतो, राहतो वगैरे वगैरे. कधी पासून हे सगळं असं असावं? याचं उत्तर आपल्या सारख्या सामान्यांपेक्षा हा ज्या कोणत्या विषयाचा विषय असेल त्या विषयाच्या निष्णातांना जास्त चांगलं माहित असेल. तरी, आपला एक सामान्य माणूस म्हणून या भूमीवर अधिकार आहे आणि त्याच अधिकाराने आपण आपला एक अंदाज लावू शकतो. म्हणजे ज्ञानेश्वर-नामदेव इथे आपल्याला या मराठी राज्याची - महाराष्ट्राची - सुरुवात झाली असावी, असा अंदाज लावता येईल.म्हणजे आजच्या आपल्या मराठी म्हणता येईल अशा संस्कृतीची सुरवात तिथून झाली असं आपण समजू शकतो. किंवा मला जे मांडायचं त्या साठी ते सोयीचं आहे म्हणून समजा हवं तर! पण मीच कशाला वारकरी साहित्यातच संत बहिणाबाईंनी लिहून ठेवलयं - संतकृपा झाली । इमारत फळा आली ॥ १ ॥ ज्ञानदेवें रचिला पाया । उभारिलें देवालया ॥ २ ॥ नामा तयाचा किंकर । तेणें रचिलें तें आवार ॥ ३ ॥ जनार्दन एकनाथ । खांब दिधला भागवत ॥ ४ ॥ तुका झालासे कळस । भजन करा ...

Publishing business basics

Basic Steps: 1. Decide name for the company 2. Register the company with ministry - you will need an attorney (Lawyer for that) 3. Register with Registrar of News Papers in India if it's a magazine/News paper.  4. Study the relevant acts in general or get them known from the lawyer 5. Start publishing Following are details regarding the same (not that well written) : ----- Some starts and books; * Start Your Own Self-Publishing Business (Entrepreneur Magazine's Start Up) by Entrepreneur Press  * How To Start And Run A Small Book Publishing Company: A Small Business Guide To Self-Publishing And Independent Publishing by Peter I. Hupalo  * Art & Science Of Book Publishing by Herbert S., Jr. Bailey  * This Business of Books: A Complete Overview of the Industry from Concept Through Sales by Claudia Suzanne Raja Rammohun Roy National Agency for ISBN West Block-I, Wing-6, 2nd Floor, Sector -I, R.K. Puram, New Delhi-110066 Some new things and t...