1

I have downloaded and "manually" installed JDK 10 for Linux 64bit edition (for Ubuntu 16.04), Oracle Java SE Development Kit (note: I wanted to download the Java9 JDK but this is no longer supported and I was referred to the Java 10 SE Development kit instead).

When I try running jshell from a terminal window I get the following error,

The program 'jshell' is currently not installed. To run 'jshell' please ask your administrator to install the package 'openjdk-9-jdk-headless' You will have to enable the component called 'universe'

enter image description here

enter image description here

enter image description here

enter image description here

I dont know why the message is asking me to install openjdk when I have installed the classic java version. When I run "which jshell" I dont get any details returned.

Can anyone help me get jshell installed and working ?

robbie70
  • 1,515
  • 4
  • 21
  • 30
  • According to your second screenshot, it seems that JShell is correctly installed. Did you try to run JShell in that folder using `./jshell`? If it works, the problem is just path configuration. – Mincong Huang May 10 '18 at 10:21
  • thanks Mincong - I just tried that and yes that works ! I am a bit confused, if I use "update-alternatives" to configure my java version - does that only expose the files that I have configured i.e. "java" and "javac" ? do I need to add the java 'bin' directory to my path explicitly as well inorder to access all the other files in the `bin` directory ? – robbie70 May 10 '18 at 10:22
  • Sorry, I don't know about update-alternatives and I don't use Linux... I'll let other to help you on this field. The only thing for sure is that the `bin` folder of JDK must be present in your PATH—so that you can call `jshell` directly. – Mincong Huang May 10 '18 at 10:30
  • I don't see the Java Directory in your PATH – Yassin Hajaj May 10 '18 at 10:39

3 Answers3

2

JShell is a development tool. You should download and install the Java Development Kit to run jshell, not just the Java Runtime Environment.

ernest_k
  • 44,416
  • 5
  • 53
  • 99
  • I do have that - if you check the link I posted above you can see what I downloaded. I just checked the "bin" directory and can see that "jshell" is included there. – robbie70 May 10 '18 at 10:12
  • 1
    @robbie70 how about including /bin in PATH then? – Eugene May 10 '18 at 10:13
  • @robbie70 Then your `PATH` variable includes the JRE installation's `bin` directory. You will have to change its value to point to the JDK's bin directory, instead. – ernest_k May 10 '18 at 10:17
  • Eugene / Ernest - I dont have java included in my `path`. Instead I used `update-alternatives` to configure my java version. – robbie70 May 10 '18 at 10:21
  • Then that's where the change must be done. Check this: https://askubuntu.com/questions/315646/update-java-alternatives-vs-update-alternatives-config-java – ernest_k May 10 '18 at 10:24
1

On Linux, and specificallly Ubuntu, development tools are not best installed via apt. The exception to prove the rule is RVM, which is installed via apt purely so that it will download ruby and ruby gems dynamically outside of apt.

For Java, the equivalent is SDKman, which is installed via curl. Once you have SDKman then you can install Java and other Java type tools.

SDKman in action:

thufir@dur:~$ 
thufir@dur:~$ sdk list java
================================================================================
Available Java Versions
================================================================================
     12.ea.20-open                                                              
     11.0.1-zulu                                                                
 > * 11.0.1-open                                                                
     10.0.2-zulu                                                                
     10.0.2-open                                                                
     9.0.7-zulu                                                                 
     9.0.4-open                                                                 
   * 8.0.192-zulu                                                               
     8.0.191-oracle                                                             
     7.0.201-zulu                                                               
     6.0.119-zulu                                                               
     1.0.0-rc-10-grl                                                            
     1.0.0-rc-9-grl                                                             
     1.0.0-rc-8-grl                                                             


================================================================================
+ - local version
* - installed
> - currently in use
================================================================================
thufir@dur:~$ 

Generally, umake, or Ubuntu Make, will install IDE or other development tools. Currently, umake is best installed as a snap.

The upshot is to first install SDKman, then snap, then use snap to install umake. Between umake and SDKman your tools should be up to date.

(Ruby uses a similar RVM, which inspired SDKman.)

Thufir
  • 8,216
  • 28
  • 125
  • 273
0

I followed the tip given by Ernest Kiwele and others above and set-up my JAVA_HOME partly as described in How to set JAVA_HOME in Linux for all users but also by creating a sh script in my profile.d directory. Thank you for the help.

enter image description here

I dont feel completely comfortable with my solution since I have configured my Java using update-alternatives. I dont know why people advise to use update-alternatives to set the version of Java to use if the other depending variables aren't set-up at the same time.

enter image description here

robbie70
  • 1,515
  • 4
  • 21
  • 30