Hot questions for Using Ubuntu in apt


I've installed oracle JDK-8 on ubuntu 14.04 manually. but whenever I want to install a package that needs jdk8, apt-get tries to install jdk 8 again. my country is restricted so oracle server won't allow me to download jdk8.

$java -version

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

and the results of apt-get are:

download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

with this error, apt-get won't finish the installation.


oracle-java8-installer is not able to download file. So downlaod it manually from Oracle site and put into folder /var/cache/oracle-jdk8-installer/. And try to install oracle-java8-installer again. This solved the problem for me.

Step by step:

  • Check what file oracle-java8-installer is not able to download. You can see it in installation log. Let's suppose it's jdk-8u111-linux-x64.tar.gz
  • Google it jdk-8u111-linux-x64.tar.gz and you'll find exact page on Oracle site where to download it from. For our example it's
  • Download jdk-8u111-linux-x64.tar.gz file and put in into folder /var/cache/oracle-jdk8-installer/.
  • And try to install oracle-jdk8-installer again: sudo apt-get install oracle-java8-installer Installation should finish successfully.


I am trying to write a simple java calculator program capable of addition, multiplication, subtraction, and division.

Within Eclipse, it works perfectly. But when I try to run it on Ubuntu Terminal, the symbol "*" is not recognized as an argument.

For example, when I type: java Calculate 7 * 8, the program does not read in the input as three pieces of arguments.

I am curious to know the cause of this problem and possibly a fix to this.


When you do this on most command lines, the * is going to be expanded to the list of files in the directory. Try escaping it with quotes...

java Calculate 7 "*" 8


java Calculate 7 '*' 8

Edit: Thanks @Danny Daglas


Gradle Manual (1) suggests to verify Gradle Wrapper Jar against officially published release checksums (2). When generating with gradle wrapper command and gradle being installed via apt-get install gradle resulting wrapper Jar's checksum doesn't match any from (2).

Checked on Ubuntu 19.10, 18.04.3.


Many Linux distributions build their own distribution of Gradle, though I have no idea why. I assume this is the case for Ubuntu. And when you use a custom built distribution, it is not unreasonable to see why the checksum might end up different than the official ones.

You should only use a locally installed distribution for the first time you initialize a Gradle project. So I expect this problem will go away once you change the version for the project. For example, assume you are on a custom version 6.0 now, and you run gradlew wrapper --gradle-version 6.0.1 --distribution-type all twice in a row* (notice the 'w'), then it will update your project distribution of Gradle to a newer and official version. I would be surprised if the checksum didn't match after that.

Alternatively, you could also download the wrapper jar manually.

*) It is good practice to run the wrapper script twice as the wrapper scripts themselves are only updated on the second run once the newer version has been downloaded.


I want to install openjdk on ubuntu. I found two ways to install it.

The first is typing "sudo apt-get install openjdk-8-jdk" on terminal.

The second is downloading the binary file such as *.tar.gz and then unpack the file and set environment variables JAVA_HOME&PATH.

So, is there any difference between this two methods? I mean, will it cause different results?

Thanks a lot.


With the first approach, the installation is controlled by Debians Apt package manager and will receive updates, with the second one you will have to do that manually.


I Build Image from Dockerfile:

FROM ubuntu
RUN apt-get update

Then save the image to my local computer and I got this file for example:


I'm trying to decompress ubuntu bionic lz4 file in Java lz4-java:

 LZ4Factory factory = LZ4Factory.fastestInstance();
 byte[] encoded = Files.readAllBytes(Paths.get("<Path to file>"));
 final int compressedLength = data.length;
            LZ4Compressor compressor = factory.fastCompressor();
            byte[] restored = new byte[compressedLength];
            LZ4SafeDecompressor decompressor2 = factory.safeDecompressor();
            decompressor2.decompress(data, 0, compressedLength, restored, 0);

I use this dependency:


But I still get this exception:

Exception in thread "main" net.jpountz.lz4.LZ4Exception: Error decoding offset 4 of input buffer
    at net.jpountz.lz4.LZ4JNISafeDecompressor.decompress(
    at net.jpountz.lz4.LZ4SafeDecompressor.decompress(
    at org.whitesource.fs.Main.main(


Assuming your archive uses the official LZ4 frame format, you may prefer this LZ4 Java version which supports LZ4 frame format.


What's the easiest way to capture a process ID and kill it?

When I type ps -ef | grep wso2 I get the following. I need to capture the first process ID and kill it in one command.

ubuntu    5460     1  4 08:38 pts/5    00:01:15 /usr/lib/jvm/jdk1.7.0_79//bin/java -Xbootclasspath/a: -Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/logs/heap-dump.hprof -classpath /usr/lib/jvm/jdk1.7.0_79//lib/tools.jar:/home/ubuntu/UES/wso2ues-2.0.0-m4/bin/org.wso2.carbon.bootstrap-4.4.1.jar:/home/ubuntu/UES/wso2ues-2.0.0-m4/bin/tcpmon-1.0.jar:/home/ubuntu/UES/wso2ues-2.0.0-m4/bin/tomcat-juli-7.0.59.jar:/home/ubuntu/UES/wso2ues-2.0.0-m4/lib/commons-lang-2.6.0.wso2v1.jar -Djava.endorsed.dirs=/home/ubuntu/UES/wso2ues-2.0.0-m4/lib/endorsed:/usr/lib/jvm/jdk1.7.0_79//jre/lib/endorsed:/usr/lib/jvm/jdk1.7.0_79//lib/endorsed -Dcatalina.base=/home/ubuntu/UES/wso2ues-2.0.0-m4/lib/tomcat -Dwso2.server.standalone=true -Dcarbon.registry.root=/ -Djava.command=/usr/lib/jvm/jdk1.7.0_79//bin/java -Dcarbon.home=/home/ubuntu/UES/wso2ues-2.0.0-m4 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/conf -Djava.util.logging.config.file=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/conf/etc/ -Dcomponents.repo=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/components/plugins -Dconf.location=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/conf -Dcom.atomikos.icatch.file=/home/ubuntu/UES/wso2ues-2.0.0-m4/lib/ -Dcom.atomikos.icatch.hide_init_file_path=true -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dfile.encoding=UTF8 -DworkerNode=false org.wso2.carbon.bootstrap.Bootstrap
ubuntu    5725  4327  0 09:05 pts/5    00:00:00 tail -1000f ../repository/logs/wso2carbon.log
ubuntu    5727  2159  0 09:06 pts/3    00:00:00 grep --color=auto wso2


Esiest way to kill process by id (if you want to kill java process) is

kill `jps | grep wso2 | awk '{ print $1 }'`

jps - Lists the instrumented Java Virtual Machines (JVMs) on the target system

Detailed info - man jps


I am working on a site where I have to build a module to capture the web screen on click event. I referred few posts in SO and I tried using Robot (java.awt.Robot) and JNA (com.sun.jna.*) and both the cases I was successful when I tried from my local machine or a local tomcat server. It did capture the web page and I am using Java 1.7

When I deployed the code in my Ubuntu (Ubuntu 14.04.4), I started having challenges in both the cases.

With JNA, I keep getting the exception as mentioned below. FYI, I have mentioned the versions of Java that I am using in Ubuntu. I am sure this is something to do with configuration or I am not sure if my Java version is not picked properly by the system. Any guidance will be helpful. I referred through the internet but didnt find any guidance to solve this issue

The Java version I am using is javac 1.7.0_131 ( java-7-openjdk-amd64)

java.lang.UnsatisfiedLinkError: Error looking up function 'GetDesktopWindow': /usr/lib/jvm/default-java/bin/java: undefined symbol: GetDesktopWindow
    at com.sun.jna.Function.<init>( ~[jna-4.2.2.jar:4.2.2 (b0)]
    at com.sun.jna.NativeLibrary.getFunction( ~[jna-4.2.2.jar:4.2.2 (b0)]
    at com.sun.jna.NativeLibrary.getFunction( ~[jna-4.2.2.jar:4.2.2 (b0)]
    at com.sun.jna.NativeLibrary.getFunction( ~[jna-4.2.2.jar:4.2.2 (b0)]
    at com.sun.jna.Library$Handler.invoke( ~[jna-4.2.2.jar:4.2.2 (b0)]
    at com.boot.service.$Proxy118.GetDesktopWindow(Unknown Source) ~[na:na]
    at com.boot.service.AuditService.getScreenshot( ~[AuditService.class:na]
    at com.boot.service.AuditService.captureScreen( ~[AuditService.class:na]
    at com.boot.service.AuditService.captureScreenshotAndStore( ~[AuditService.class:na]
    at com.boot.controller.AuditController.captureScreenshotAndStore( ~[AuditController.class:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke( ~[na:1.7.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[na:1.7.0_131]
    at java.lang.reflect.Method.invoke( ~[na:1.7.0_131]
    at ~[spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]

When I list my JVM folder, these are the different version of Java I see, default-java java-1.7.0-openjdk-amd64 java-7-openjdk-amd64 java-7-oracle java-8-oracle

With Robot, it worked good in my local but failed in Ubuntu with the following error.

java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit
    at java.lang.Class.forName0(Native Method) ~[na:1.7.0_131]
    at java.lang.Class.forName( ~[na:1.7.0_131]
    at java.awt.Toolkit$ ~[na:1.7.0_131]
    at Method) ~[na:1.7.0_131]
    at java.awt.Toolkit.getDefaultToolkit( ~[na:1.7.0_131]

I referred few posts which asked to update the headless variable to true. I am using Spring boot and not sure how to set that but I did System.setProperty("java.awt.headless", "false"); as part of the service constructor. It didnt help either


The GetDesktopWindow function is part of the Microsoft Windows API. Running it on a Linux environment won't work. I believe it works on your machine because your PC is a Microsoft Windows OS.

There is an OS independent solution, here on SO that accomplishes your requirements.


I am trying to install java 7 on Ubuntu 14.04 following the instructions at Installing Java 7 on Ubuntu .

When I try to install java 7, I get a HTTP 404 ERROR.

Does anybody know if installing java 7 using these instructions is still supported?

Am I missing something that is obvious to everybody else and not to me‽

Thank you in advance for advice.

I executed the following commands as per the instructions:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Here is the output:

Reading package lists... Done
Building dependency tree
Reading state information... Done
oracle-java7-installer is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up oracle-java7-installer (7u67+7u60arm-0~webupd8~4) ...
Please report to author unsupported platform 'ppc64'.
Proceeding without web browser plugin support
Please report to author unsupported platform 'ppc64'.
Proceeding without web browser plugin support
Downloading Oracle Java 7...
--2014-09-01 16:26:08--
Resolving (,
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: [following]
--2014-09-01 16:26:09--
--2014-09-01 16:26:09--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: [following]
--2014-09-01 16:26:09--
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2014-09-01 16:26:10 ERROR 404: Not Found.

download failed
Oracle JDK 7 is NOT installed.
dpkg: error processing package oracle-java7-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
E: Sub-process /usr/bin/dpkg returned an error code (1)


You are getting 404 error meaning page not found. It looks like though the connection was established package manager could not download the tar.gz file.

If it is some internal error from oracles site retry should so it. However if you are behind some proxy that is not allowing this transfer there is not much you can do.

Either way try doing


and see if you can download the file.


I'm trying to install Java JDK 8 with this instruction:

apt-get update -y
apt-get install -y python-software-properties
add-apt-repository ppa:webupd8team/java
apt-get update -y
apt-get install -y  oracle-java8-installer

but I get a 404 while I'm running last command:

Connecting to (||:80... connected. HTTP request sent, awaiting response... 404 Not Found 2017-10-18 10:33:03 ERROR 404: Not Found.

download failed

How many days since this problems happens? It is strange a 404 for a Java installer. Isnt'it? Any workaround?


You can try to install java 8 manually. Just download java (tar.gz) from oracle site.

Then, create directory for your jdk like (of course if folder doesn't exist)


and extract java into created folder.

$tar -zxf jdk-8u152-linux-x64.tar.gz -C /opt/jdk

Then, it is very important, to set it as the default JVM in your machine run. Just use that command:

$update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_152/bin/java 100


$update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_152/bin/javac 100

Now, verify that java installed correctly.

$java -version