Installing jdk without sudo?
You can install the JDK in a non-standard directory, for example under your own home directory, without special permissions.
You just need to point PATH and JAVA_HOME and Eclipse at it.
Installing JDK without administrator privileges
Here is a workaround to install java without admin privileges or without administrator password. For this you need cygwin installed which does not require admin privileges.
In the utils make sure you select cabextract.exe to install it.
Fireup cygwin bash shell.
Type cabextract jdk1.6.exe <-- jdk file name
this will extract all the files into the current directory.
Move tools.zip to a new directory and unzip it using cygwin or windows explorer. This will be your java directory.
Hint: Try to subsitite 7zip instead of cabextract and cygwin. If it works it will be much faster.
Edit: This doesn't get you a working JDK with the latest versions of jdk 6 and 7. Many of the jar files (eg rt.jar) are compressed so they need to be decompressed using unpack200.
Just go through each directory looking for files with a .pack extension and unpack them using unpack200, eg: .\jre\bin\unpack200 .\jre\lib\rt.pack .\jre\lib\rt.jar
This allows you to run java programs however I still had trouble with Eclipse as there was some issue with annotations, so there's probably another step that is missing.
In the answers to this similar question on Superuser is available a script that automatically finds all .pack files and unpacks them in the right folders.
How to install java locally - no root - on linux, if possible?
It is quite easy...
Download the JDK as a tarball from Oracle (a simple google search will yield the link).
Unzip it somewhere in your $HOME (for instance, $HOME/jdk
).
Set JAVA_HOME
to the path of the root JDK install; then prepend $JAVA_HOME/bin
to your PATH
.
And off you go.
Here I have a particular setting insofar as I run three different major versions of the JDK: 6, 7, 8. For instance, here is my source file for setting the current shell to use Java 8:
$ cat ~/.jdk/8
export JAVA_HOME=/opt/sunjdk/1.8/current
export PATH="$JAVA_HOME/bin:$PATH"
And in /opt/sunjdk/1.8
(given that /opt/sunjdk
is writable by my user hence I don't need to be root
):
$ ls -l /opt/sunjdk/1.8/* -d
lrwxrwxrwx 1 fge fge 11 Oct 30 10:09 /opt/sunjdk/1.8/current -> jdk1.8.0_25
drwxr-xr-x 1 fge fge 274 Mar 18 2014 /opt/sunjdk/1.8/jdk1.8.0_05
drwxr-xr-x 1 fge fge 274 Sep 18 02:44 /opt/sunjdk/1.8/jdk1.8.0_25
(and yes, I was root
to begin with so as to grant write permissions for /opt/sunjdk
to "my" user; if you have no such liberty, just create another directory in your home)
How to install the JDK on Ubuntu Linux
Referring to Ask Ubuntu question How to set JAVA_HOME for OpenJDK?,
How to install Open JDK
(Java developement kit) in Ubuntu (Linux)?
Open Terminal from Application Dash or press Ctrl+Alt+T
Update repository:
sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier
sudo apt updateOptional: To search available distributions of
openjdk
, use the following command:apt search openjdk
Install the appropriate version with the following command:
sudo apt install openjdk-8-jdk
sudo apt install openjdk-8-source #this is optional, the jdk source codeFor
JAVA_HOME
(Environment Variable) type command as shown below, in "Terminal" using your installation path...export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
(Note:
/usr/lib/jvm/java-8-openjdk
is symbolically used here just for demostration. You should use your path as per your installation.)For
PATH
(Environment Variable) type command as shown below, inTerminal
:export PATH=$PATH:$JAVA_HOME/bin
To check your installation:
java -version
I want to install Java through the command line but I don't have sudo access.
You don't really have to install it. You should be able to navigate into [your jdk folder]/bin and run ./javac -version.
So just add the bin folder to your path and set $JAVA_HOME and you're good to go.
How to install JDK 11 under Ubuntu?
Now it is possible to install openjdk-11 this way:
sudo apt-get install openjdk-11-jdk
(Previously it installed openjdk-10, but not anymore)
How to install JDK 10 under Ubuntu?
Update: JDK 11 Now Available
sudo apt-get install openjdk-11-jdk
For JDK 10
Option 1: Easy Installation (PPA)
sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install oracle-java10-installer
Then set as default with:
sudo apt-get install oracle-java10-set-default
And finally verify Installation with:
$ java -version
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
Source: Linux Uprising
Option 2: Manual Installation
Download OpenJDK 10 binaries for Linux.
Untar the downloaded archive:
tar xzvf openjdk-10_linux-x64_bin.tar.gz
Move the extracted archive to where your system keeps your installed JDKs:
sudo mv jdk-10 /usr/lib/jvm/java-10-openjdk-amd64/
Add the new Java alternative:
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-10-openjdk-amd64/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-10-openjdk-amd64/bin/javac 1Update your system's java alternatives and choose JDK 10:
$ sudo update-alternatives --config java
here are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-9-openjdk-amd64/bin/java 1091 auto mode
* 1 /usr/lib/jvm/java-10-openjdk-amd64/bin/java 1 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
3 /usr/lib/jvm/java-9-openjdk-amd64/bin/java 1091 manual mode
Press <enter> to keep the current choice[*], or type selection number:and
$ sudo update-alternatives --config javac
There are 3 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-9-openjdk-amd64/bin/javac 1091 auto mode
1 /usr/lib/jvm/java-10-openjdk-amd64/bin/javac 1 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/bin/javac 1081 manual mode
3 /usr/lib/jvm/java-9-openjdk-amd64/bin/javac 1091 manual mode
Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/jvm/java-10-openjdk-amd64/bin/javac to provide /usr/bin/javac (javac) in manual modeVerify your installation with:
$ java --version
openjdk 10 2018-03-20
OpenJDK Runtime Environment 18.3 (build 10+46)
OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)and
$ javac --version
javac 10Done
If you prefer Oracle's JDK, download it and follow the installation steps as shown above.
Related Topics
Scale PDF to Add Border for Printing Full Size Pages
Pyinstaller on 32-Bit Linux - Importerror: The 'six' Package Is Required
Stop a Running Dotnet Core Website Running on Kestrel
Using '*' in Docker Exec Command
"Hello World" Function Without Using C Printf
Awk, Pipe and Tail -F Giving Unexpected Behavior
Cache Coloring on Slab Memory Management in Linux Kernel
Force Netcat to Send Messages Immediately (Without Buffering)
Conditional Awk Hashmap Match Lookup
Scp Command Between 2 Servers with 2 Different .Pem Keys
Exactly When Tasklet Runs After It Is Schedule by Isr
X86 Assembly, Little Endianness Not Being Followed(Or Is It) (Linux)
Ensure Config.H Is Included Once
Linux Stand Alone Executable Generation
Ssl: Nancyfx Selfhost Mono Linux (Pi)
Cmake Error: The Following Variables Are Used in This Project, But They Are Set to Notfound