Source : http://stackoverflow.com/questions/10268583/how-to-automate-download-and-installation-of-java-jdk-on-linux
UPDATED FOR JDK 8u45
RPM:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm
TAR GZ:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.tar.gz
RPM using curl:
curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm > jdk-8u45-linux-x64.rpm
- -j -> junk cookies
- -k -> ignore certificates
- -L -> follow redirects
- -H [arg] -> headers
curl
can be used in place of wget
.
UPDATED ANSWER ON 6th September 2014 (JDK 7u67)
I am updating this answer to take into account the fact that Oracle has changed their cookie policy. Thanks to Det for pointing out a simpler method than what I had originally specified.
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz
Once again, make sure you specify the correct URL for the version you are downloading. You can find the URL here: Oracle JDK download site
ORIGINAL ANSWER FROM 9th June 2012
If you are looking to download the Oracle JDK from the command line using wget
, there is a workaround. Run the wget
command as follows:
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz"
Be sure to replace the download link with the correct one for the version you are downloading.
Voici un copié-collé d’une procédure de compilation/configuration/installation d’Apache 2.2 en concert avec Tomcat 5.5 que j’ai à utilisé de temps en temps dans mon travail. Si ça peux vous être utile.
Si vous êtes l’auteur de cette procédure n’hésitez pas à me le dire pour que je vous cite, j’ai oublié d’où provient ces informations. (If you are this procedure’s author, please do not hesitate to tell me so I can quote you).
Here is what you need to do to have a running webserver using Apache and Tomcat:
If you’ve already installed required packages and are ready to install Apache and Tomcat, go to STEP1?. If you are starting after installing the OS and you still have no packages installed at all, you might want to use apt-get install to get the following packages:
bison,flex,g++,make (If you’re going to be building anything from source, these will help)
bzip2,unzip (Useful for compressing/uncompressing archives)
dnsutils (DNS utilities including nslookup)
lynx (Text Based Browser – useful for testing your websites if you need to)
nmap,tcpdump,tethereal,traceroute (More advanced layer 1-3 troubleshooting utilities)
ntpdate (Make sure you install this so all your machines have the same system time)
libssl-dev,openssl (Necessary if you’re installing apache with SSL)
ssh (NEVER FORGET TO INSTALL THIS)
vim (Better text editor, after you install this, make sure you edit /etc/vim/vimrc and uncomment the line that says syntax=on)
First, install this:
apt-get install ssh vim ntpdate
Here is what the line that you would type to get all of this on a new server.
apt-get install bison bzip2 dnsutils flex g++ libssl-dev lynx make nmap openssl tcpdump tethereal traceroute unzip
STEP1 – downloads
Downloading Java, Apache2.2, Tomcat 5.5
go to /usr/src on your machine and run wget on the following files. (you can use “copy link location” in Firefox on the links that say “This is the latest version […]” then paste the links in your console)
Java 1.4.2_11 from http://java.sun.com/j2se/1.4.2/download.html. Get the J2SDK non-rpm linux installer.
Another alternative is to copy the file from zeus:
scp [email protected]:/usr/src/j2sdk-1_4_2_11-linux-i586.bin /usr/src
Latest Apache2 from http://httpd.apache.org. Get the tar of the source. This is the latest version (2.2.0) on 20060403
Latest Tomcat 5.5.16 from http://tomcat.apache.org/download-55.cgi#5.5.16. Get the tar of the binary. This is the latest version (5.5.16) on 20060403
STEP 2 – installation
Installing everything you downloaded above
installing Apache
Go to /usr/src/ and untar the apache archive (use tar -xvf and add either z for gunzip or j for bzip2) go into the apache installation directory (usually this is /usr/src/httpd-2.2.0) and do the following:
./configure –prefix=/usr/local/apache-2.2.0 –enable-ssl –enable-cgi –enable-so –enable-rewrite –enable-proxy –enable-proxy-ajp
If you want to know what the options do, run ./configure –help Also, please make sure that the prefix fits your version of apache and that you are NOT overwriting anything. Finally, make sure that the configure command completed successfully and that you are not lacking any libraries (see above for libraries you might need).
Now type:
make
make install
Now, go to /usr/local/ and make a Symbolic Link on the new apache install called apache:
ln -s apache-2.2.0 apache
installing Tomcat
Go to /usr/local/ and untar the tomcat installer:
tar -zxvf /usr/src/jakarta-tomcat-5.5.16.tar.gz
This will create a new directory called jakarta-tomcat-5.5.16 in /usr/local/. You want to make a Symbolic Link to that directory called tomcat (look at the example in step a to see how to create a symlink)
You also need to edit /usr/local/tomcat/bin/catalina.sh to include the following:
JAVA_HOME=/usr/local/java
TOMCAT_HOME=/usr/local/tomcat
CATALINA_HOME=/usr/local/tomcat
JAVA_OPTS=”-server -Xmx200m -Dfile.encoding=ISO8859-1″
export LD_ASSUME_KERNEL=2.4.1
It is sometimes necessary to add but you should be sure you need it! Don’t add this unless you are sure you have to.
installing Java
Go to /usr/src/ and make the installer executable:
chmod +x j2sdk-1_4_2_11-linux-i586.bin
Now go to /usr/local/ and run the executable by typing the following (don’t change directories!):
/usr/src/j2sdk-1_4_2_11-linux-i586.bin
This will create a new directory called j2sdk1.4.2_11 in /usr/local/.
You want to make a symlink to that directory called java
Don’t forget to add startup scripts or links in /etc/init.d/ to make sure the applications start when the machine starts.
Et voilà! You are now done installing Apache and Tomcat! All you have to do at this point is add the configuration for the sites in /usr/local/apache/conf/httpd.conf and /usr/local/tomcat/conf/server.xml
Bon, finalement, j’ai décidé de n’écrire qu’en Français (ou du moins le franglais avec plein de fautes) sur mon blog. En effet, je me dis que puisque que j’ai une si belle langue, autant en profiter.
Bon pour revenir au sujet qui nous intéresse, c’est-à-dire l’informatique.
Durant mes vacances d’été, je suis en train d’apprendre la platefore JEE5 (Java Enterprise Edition 5) avec les EJB3, JSF, Web Services, et JMS grâce à un merveilleux livre que j’ai découvert. Ce merveilleux livre est Java EE 5 d’Antonio Concalves dans la collection les Cahiers du Programmeurs des éditions Eyrolles. Cet excellent livre alterne entre les passages nous montrant la théories et les passages plus pratique où du code fonctionnel est implémenté. En effet, vous suivrez le développement de commerce électronique tout au long du livre.
Pour plus d’informations concernant le livre, je vous suggère d’allé consulter le site de l’auteur : http://www.antoniogoncalves.org