Installing Java 7, 8 or 12 in Ubuntu

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

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, but you may want to move to Oracle 7 or 8 instead:

sudo apt-get install default-jre

Oracle JDK 7

This is the latest stable version.

sudo apt-get install oracle-java7-installer

Oracle JDK 8

Get repositories to install Java 8

$ sudo apt-get install python-software-properties
(Deprecated in Ubuntu 18.04)

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update

Now Install Java 8
$ sudo apt-get install oracle-java8-installer

Manage various Java 8 Versions
$ sudo update-alternatives --config java

Oracle JDK 12
$ sudo add-apt-repository ppa:linuxuprising/java
$ sudo apt update
$ sudo apt install oracle-java12-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:

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:

/usr/lib/jvm/java-7-oracle

/usr/lib/jvm/java-6-openjdk-amd64

/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

Disable SSL v3.0 Vulerability

Instructions to disable SSL v3.0 in Oracle JDK and JRE

Applies to
Starting with the January 20, 2015 Critical Patch Update releases (JDK 8u31, JDK 7u75, JDK 6u91, Oracle JRockit 28.3.5, Oracle JRockit R27.8.5, and above) the Java Runtime Environment has SSLv3 disabled by default.

Oracle JRockit 28.3.5 and R27.8.5 users - please follow the instructions for Java 6 users.

Refer: http://www.oracle.com/technetwork/java/javase/documentation/cve-2014-3566-2342133.html

 

JSFiddler Tealeaf Test

Tealeaf-JSFiddle-Test-2015-08-10_17-04-20

Refer: http://jsfiddle.net/crd9abzd/2/

Source: JSFiddler-Tealeaf-Test.txt

External Resources:
https://qabook.hollandamerica.com/secondaryFlow/assets/analytics/tealeaf/tealeaf.4.0.0.1607.js?v=201507240707

HTML
<div id="report"></div>

JavaScript
var iteration = 0;
var reportDiv = document.getElementById("report");
var interval = setInterval(function(){
try{
iteration++;
TLT.flushAll();
reportDiv.innerHTML = "Minutes elapsed "+(iteration/60).toFixed(2)+" minutes";
}catch(e){
console.log(e);
reportDiv.innerHTML = "Tealeaf broke after "+(iteration/60).toFixed(2)+" minutes";
clearInterval(interval);
}
}, 1000);

CSS
None

Using Akamai Pragma headers to investigate or troubleshoot Akamai content delivery

Use ModifyHeaders for Firefox
Action: Add
Name: Pragma
Value: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no
Comment: Akamai Pragma

Refer: https://community.akamai.com/community/web-performance/blog/2015/03/31/using-akamai-pragma-headers-to-investigate-or-troubleshoot-akamai-content-delivery

Akamai servers are configured to provide plenty of useful information using HTTP headers - the key to extracting this information is making a HTTP request along with some custom Pragma headers. Below is the most commonly used set of Pragma request headers:

Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-get-request-id

And here is the explanation of what can be extracted using these headers as a response from Akamai Edge Server:

X-Check-Cacheable: NO
This header simply indicates whether this particular URL can be cached on Akamai or not.

X-Akamai-Request-ID: 2256a92
Request ID provides a unique request identifier on Akamai network. Value of this header can be used to trace a request on Akamai network by support representative.

X-Cache: TCP_MISS from a165-254-246-9.deploy.akamaitechnologies.com

X-Cache-Remote: TCP_HIT from a23-67-252-148.deploy.akamaitechnologies.com
Values of X-Cache headers mention which Akamai servers participated in serving your request. TCP_MISS/TCP_HIT will tell whether the content was served from cache (TCP_HIT) or if the machine had to go forward to fetch the file from somewhere else (TCP_MISS). X-Cache headers can also give an IP address of Akamai machine serving the content - as in the example above - the machines serving content are 165-254-246-9 and 23-67-252-148 - just replace dashes with dots and you will get an exact Akamai IP address!

A few other useful cache responses:

TCP_HIT: Object was fresh in cache and object from disk cache.
TCP_MISS: Object was not in cache, server fetched object from origin.
TCP_REFRESH_HIT: Object was stale in cache and was successfully refreshed with the origin on an If-Modified-Since request.
TCP_REFRESH_MISS: Object was stale in cache and refresh obtained a new object from origin in response to our IF-Modified-Since request.
TCP_REFRESH_FAIL_HIT: Object was stale in cache and failed on refresh (couldn't reach origin) so the stale object was served .
TCP_IMS_HIT: IF-Modified-Since request from client and object was fresh in cache and served.
TCP_NEGATIVE_HIT: Object previously returned a "not found" (or any other negatively cacheable response) and that cached response was a hit for this new request.
TCP_MEM_HIT: Object was on disk and in the memory cache. Server served it without hitting the disk.

X-Cache-Key: /L/152/14351/1d/origin-www.akamai.com/index2.html * - depracated
This header will return a Cache Key value which is used to store content on Akamai network.

There's also crucial information in the X-Cache-Key (Thank you Iain Hunneybell!):

That /1d/ means the item is on a 1 day cache setting. Useful if you want to check. Useful ones to look out for are:
0s: 0 second cache meaning serve from cache but revalidate on every request, e.g. check origin but don't re-download unless changed
000: Non-cacheable...a key code to recognise
5s: 5 (or however many) seconds
5m: 5 (or however many minutes)
5h: You'll never guess this one!

Small point:
akamai-x-get-cache-key has actually been deprecated because it doesn't indicate if a query string has been ignored in the cache key. It also shows serial, CP Code and TTL, which are not part of the cache key used to store the object.
While the information given in X-Cache-Key is useful it can be misleading, for example the TTL shown won't reflect any baseline value being overridden by origin cache-control or edge control headers. It can also show extra query parameters added by internal processes like RUM or FEO.

You should use akamai-x-get-true-cache-key and X-True-Cache-Key to get the real cache key used to store the object. It will represent the parts of the original URI used to form the key after any metadata rule processing.

Akamai Pragma HTTP headers can be injected into your request by one of the browser extensions or one of HTTP debugging applications. Some most popular examples include:

- Charles Proxy - HTTP/Web Debugging Proxy software
- Fiddler - free web debugging proxy
- Modify Headers Firefox plugin
- Firebug - another powerful Firefox plugin
- For Chrome, try experimenting with this extension: CDN Headers & Cookies - Chrome Web Store (Thank you Dwi Taniel!)