Ubuntu which java is running

How can I check which JRE version I have?

According to the program I am trying to start, it requires Oracle(R) Java(TM) Runtime Environment 7 or 8 .

The number after the 1. In this case, you’re on JRE 7. If it really needs the Oracle JRE, see askubuntu.com/q/56104/158442

1 Answer 1

You need Oracle Java which you can install like this

sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer 
sudo apt-get install oracle-java8-set-default 

Right now you have OpenJDK and as per your question you need Oracle Java. In case the JAVA_HOME is not setup properly you can do:

sudo vi /etc/environment export JAVA_HOME=/path-to-java-before-bin-dir source /etc/environment 

Should I remove the old java? I don’t want it to interfere with the new one, and the system is low on memory. Will it have any effect on the Ubuntu if I remove it?

@inf3rno. No you don’t have to. The steps that i have provided doesn’t purge openJDK. It’s just make sure that you get Oracle Java 8 from the right PPA(so that you get future updates and bug fixes) and then it will make sure that it’s Oracle Java 8 is invoked when you issue java(provided you setup path properly). If this solves your problem — mark this as answer(tick mark)

Читайте также:  Php webservice soap wsdl

Thanks! I’ll purge it, I guess programs which used that version are compatible with the oracle version.

Источник

How to Check Java Version Installed on Linux

How do I check my current Java version? There are several ways to check if Java is installed and which version is running on your system.

In this tutorial, learn how to check the Java version installed on Linux distros, including Ubuntu, CentOS, and Debian.

tutorial on checking Java version on linux

  • A user account with sudo privileges
  • Access to the command-line/terminal window
  • A version of Java

Method 1: Check the Java Version On Linux

To check the Java version on Linux Ubuntu/Debian/CentOS:

2. Run the following command:

3. The output should display the version of the Java package installed on your system. In the example below, OpenJDK version 11 is installed.

example of checking the version of java running on ubuntu linux

Note: If the output indicates there is no such package on the system, you can install it with the help of one of our guides – How to install Java on Ubuntu or How to Install Java on CentOS.

You can also check the version of the primary Java compiler – javac (pronounced “java-see”) with the command:

Check javac version on Ubuntu.

Method 2: Find Version by Checking Path Where Java is Installed

There are two ways to find the path of the Java directory.

The first option includes running a single command:

update-alternatives --list java

The system should respond with the path where Java is installed.

Check Java directory path to find the java installation version

Note: This option may not work on CentOS systems. If you have issues finding the path of the Java directory with the command above, use the alternative outlined below.

Alternatively, you can use the whereis command and follow the symbolic links to find the Java path.

Check Java path on Ubuntu.

The output tells you that Java is located in /usr/bin/java.

2. List the content of the /usr/bin/java directory:

Locate Java directory on Ubuntu.

Inspecting the directory shows that /usr/bin/java is only a symbolic link for /etc/alternatives/java.

3. Just like in the previous step, list the content of the provided path by running:

Find Java path on Ubuntu.

Finally, the output displays /etc/alternatives/java is another symbolic link and that the real path of the Java directory is /usr/lib/jvm/java-11-openjdk-amd64/bin/java.

Method 3: Search for Java in the Installed Packages List

You can also prompt the system to list installed packages and search for Java, with its version number.

Find Java by listing all installed packages.

1. To generate a list of all installed packages, use the command:

2. Scroll up/down until you find the Java packages as shown in this example.

Find Java in the installed packages list.

To avoid searching through all installed packages, list Java packages only. Prompt the system to list a specific software package. In this case, the package name is openjdk:

sudo apt list --installed | grep -i openjdk

Search for Java in the Installed packages list on Ubuntu.

Note: CentOS users need to modify the commands for listing installed packages for their package manager. Use the commands: sudo yum list installed and sudo yum list installed | grep -i openjdk instead.

With this article, you have successfully checked the Java version installed on Linux. We also covered checking the Java path and searching for Java among the installed packages.

Once the Java version is confirmed, you can start developing anything from lightweight mobile to desktop applications.

Источник

Ubuntu: How to Identify the Installed Java Version

The program is derived from a well-known programming interview book called Cracking the Coding Interview. The directory and Java files’ structure is available at https://github.com/gaylemcd/ctci/tree/master/java. To run the program, I utilize the CtCILibrary directory’s MyClass and require a specific file. I navigated to the corresponding directory and compiled QuestionB.java using a compilation command. My current concern is how to run the modified server using Java version 15 while simultaneously running the other servers using the latest version.

JAVA_HOME not working in ubuntu

As a newcomer to ubuntu , I’m attempting to employ java-8, while java-6 has already been installed on my ubuntu device. However, I only wish to utilize java-8 within my terminal for testing purposes, without affecting other software such as Eclipse that requires java-6. I’ve heard that exporting from the terminal using ubuntu may help me achieve this goal, and I’m currently attempting to do so.

$ export JAVA_HOME=/usr/lib/jvm/jdk8 $ export PATH=$PATH:$JAVA_HOME 

After completing this task, when I enter the subsequent command in the terminal-

The Java version is «1.6.0_29», followed by the Java(TM) SE Runtime Environment with build number «1.6.0_29-b11». The Java HotSpot(TM) Server VM has a build number of «20.4-b02» and operates in mixed mode.

Despite my attempts, none of the methods I’ve tried have been successful.

After $JAVA_HOME , you might have overlooked the bin directory. Please attempt this —

 $ export JAVA_HOME=/usr/lib/jvm/jdk8 $ export PATH=$JAVA_HOME/bin:$PATH 

Please note that JAVA_HOME is placed before PATH . This means that JAVA_HOME/bin is added to the existing PATH with JAVA_HOME/bin placed at the beginning of the new PATH . However, if you add JAVA_HOME/bin at the end of the current PATH , JAVA_HOME/bin will be concatenated at the end of the new PATH . In this scenario, the older JAVA_HOME (if it exists, such as jdk-6 in your case) may be found first in the new PATH , and will take precedence. To avoid mistakes, it is advisable to add JAVA_HOME/bin at the beginning instead of adding JAVA_HOME/bin at the end of the PATH .

Using multiple versions of Java in Ubuntu, I have a Ubuntu machine where I already have one JDK version which is installed. Next I have downloaded the second version into /usr/local.. Now, I want to run a program against the second JDK which is in /usr/local, i.e.,I will copy a sample .java program in /usr/local/bin and then execute it.. But the problem is, …

Java.lang.NoClassDefFoundError is thrown when running an executable file

On my Ubuntu 12.04, I’m attempting to execute Java program through the terminal.

This well-known programming interview has developed a program for the book, Cracking of the Coding Interview, and you can view the arrangement of directories and java files at.

The link provided leads to the Java implementation of «Cracking the Coding Interview» available on Github under the user gaylemcd.

While executing my code Chapter 2/Question2_5/QuestionB.java , I rely on the functionality of the LinkedListNode.java class, which is located in the CtCILibrary directory. Additionally, Chapter 2/Question2_5/PartialSum.java is also required for my task.

I navigated to the Chapter 2/Question2_5 folder and utilized the compilation command to compile QuestionB.java.

javac -cp . /../CtCiLibrary/CtCILibrary/LinkedListNode.java ./PartialSum.java QuestionB.java 

After some time spent figuring out the compiling command, the process was completed and a file named QuestionB.class was generated.

After executing java QuestionB , I encountered an error while running.

Exception in thread "main" java.lang.NoClassDefFoundError: QuestionB (wrong name: Question2_5/QuestionB) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) at java.net.URLClassLoader.access$000(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:212) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: QuestionB. Program will exit. 

Despite finding numerous references on Google, none of them proved to be helpful.

Can anyone tell me how to run this?

It’s unclear which directory you executed the java command from. Without specifying the classpath, the command will search the current directory and the classpath in the environment. Therefore, ensure that the file(s) exist in the correct location.

  • available on the classpath
  • Place the file in the directory that is suitable for their package, and if there is no package name, then put it in the current directory.

Hope this provides some help.

Updates — How to upgrade Java on Ubuntu?, kenneth@ubuntu:~$ java -version java version «1.7.0_65» Java(TM) SE Runtime Environment (build 1.7.0_65-b17) Java HotSpot(TM) Server VM (build 24.65-b04, mixed mode) Am I supposed to check back every day to see if the ppa is up-to-date again and I can start recommending people to use it again? I use the open …

How do I run a specific program that requires a different version of Java without changing the default system version of Java?

Ubuntu Server is being utilized to host multiple Minecraft servers. In order to run the latest versions of Minecraft, the latest version of Java is required. However, some of the mods are incompatible with the newest version of Java and I also want to run a modded server. Is there a way to run the modded server using Java version 15 while using the newest version for other servers? Being new to Ubuntu Server, any assistance would be greatly appreciated.

It seems possible to execute the Java file found in the directory labeled /usr/lib/jvm/java-(version)-(vendor)/bin/java just as you would utilize the java shortcut.

It would still be necessary to properly install the appropriate version of jvm.

Java — Which JRE am I using?, Open a command prompt: Version: java -version Location: where java (in Windows) which java (in Unix, Linux, and Mac) To set Java home in Windows: Right click on My computer → Properties → Advanced system settings → Environment Variable → System Variable → New . Give the name as …

Java and Ubuntu, java FTP server connection problems

After creating a basic JAVA ftp server, my aim is to establish a connection with it on my Ubuntu 11.10 system. However, every time I try the command «ftp localhost», it results in a connection failure. It appears that I may need to install a ftp server to resolve this issue, as per my research.

I’m unsure if I should proceed with this action. In case I should, which one should I choose and where can I locate it? Alternatively, could it be that I’m not executing the ftp command properly?

FTPServer.java

import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class FTPserver < public static void main(String [] args) < if (args.length != 1) throw new IllegalArgumentException( "Parameter(s): "); int threadPoolSize = 10; int port = Integer.parseInt(args[0]); final ServerSocket server; try < server = new ServerSocket(port); >catch (IOException e1) < return; >ExecutorService exec = Executors.newFixedThreadPool(threadPoolSize); while (true) < try < Socket sock = server.accept(); exec.submit(new FTPProtocol(sock)); >catch (IOException e) < System.err.println(e.getMessage()); return; >> > > 

FTPProtocol.java

import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; class FTPProtocol implements Runnable < static String greeting = "220 Service Ready.\r\n"; static String needPassword = "331 User name ok, need password.\r\n"; static String closing = "421 Service not available, closing control connection.\r\n"; static byte[] reply220 = null; static byte[] reply331 = null; static byte[] reply421 = null; Socket sock = null; public FTPProtocol(Socket so) < sock = so; reply220 = greeting.getBytes(); reply331 = needPassword.getBytes(); reply421 = closing.getBytes(); >public void run() < handleFTPClient(sock); >void handleFTPClient(Socket sock) < InputStream is = null; OutputStream os = null; byte[] inBuffer = new byte[1024]; try < is = sock.getInputStream(); os = sock.getOutputStream(); os.write(reply220); int len = is.read(inBuffer); System.out.write(inBuffer, 0, len); os.write(reply331); len = is.read(inBuffer); System.out.write(inBuffer, 0, len); os.write(reply421); sock.close(); >catch (IOException e) < System.err.println(e.getMessage()); return; >> > 

When using Linux, it is not possible to utilize port 21 without root privileges. As an alternative, you can bind to a different port such as 2121 and employ a client that enables you to specify the desired port number.

Linux — Installing Java 8 on Ubuntu, I am trying to install Java 8 on Ubuntu. Due to restrictions on download at my work place, I cannot install using apt-get. Hence, I downloaded the archive from Oracle’s website. However, when I extracted it, there was only a file inside it. How to install using that file? java linux ubuntu java

Источник

Оцените статью