简体   繁体   中英

The program 'jshell' is currently not installed when trying to run jshell on Ubuntu

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'

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

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 ?

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

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.

在此处输入图片说明

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.

在此处输入图片说明

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 .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM