AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / ubuntu / Perguntas / 1471777
Accepted
Nicholas Saunders
Nicholas Saunders
Asked: 2023-06-10 22:35:27 +0800 CST2023-06-10 22:35:27 +0800 CST 2023-06-10 22:35:27 +0800 CST

Como instalo e configuro o OpenJDK no Ubuntu a partir do Snapcraft?

  • 772

Como o OpenJDK é instalado a partir do snap para que javac e java estejam disponíveis na CLI?

nicholas@mordor:~$ 
nicholas@mordor:~$ snap list
Name                       Version           Rev    Tracking         Publisher      Notes
bare                       1.0               5      latest/stable    canonical✓     base
chromium                   113.0.5672.126    2477   latest/stable    canonical✓     -
core18                     20230503          2751   latest/stable    canonical✓     base
core20                     20230503          1891   latest/stable    canonical✓     base
core22                     20230531          750    latest/stable    canonical✓     base
cups                       2.4.2-5           872    latest/stable    openprinting✓  -
firefox                    111.0.1-2         2517   latest/stable/…  mozilla✓       -
gnome-3-38-2004            0+git.6f39565     140    latest/stable    canonical✓     -
gnome-42-2204              0+git.587e965     102    latest/stable/…  canonical✓     -
gtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical✓     -
openjdk                    20.0.1+9          1349   latest/stable    jgneff         -
snap-store                 41.3-71-g709398e  959    latest/stable/…  canonical✓     -
snapd                      2.59.4            19361  latest/stable    canonical✓     snapd
snapd-desktop-integration  0.9               83     latest/stable/…  canonical✓     -
nicholas@mordor:~$ 
nicholas@mordor:~$ openjdk.java -version
openjdk version "20.0.1" 2023-04-18
OpenJDK Runtime Environment (build 20.0.1+9-snap)
OpenJDK 64-Bit Server VM (build 20.0.1+9-snap, mixed mode, sharing)
nicholas@mordor:~$ 
nicholas@mordor:~$ java --version
Command 'java' not found, but can be installed with:
sudo apt install openjdk-17-jre-headless  # version 17.0.7+7~us1-0ubuntu1~23.04, or
sudo apt install default-jre              # version 2:1.17-74
sudo apt install openjdk-11-jre-headless  # version 11.0.19+7~us1-0ubuntu1~23.04
sudo apt install openjdk-20-jre-headless  # version 20.0.1+9~us1-0ubuntu1~23.04
sudo apt install openjdk-8-jre-headless   # version 8u372-ga~us1-0ubuntu1~23.04
sudo apt install openjdk-18-jre-headless  # version 18.0.2+9-2ubuntu1
sudo apt install openjdk-19-jre-headless  # version 19.0.2+7-0ubuntu4
sudo apt install openjdk-21-jre-headless  # version 21~14ea~us1-0ubuntu1
nicholas@mordor:~$ 
nicholas@mordor:~$ javac --version
Command 'javac' not found, but can be installed with:
sudo apt install openjdk-17-jdk-headless  # version 17.0.7+7~us1-0ubuntu1~23.04, or
sudo apt install default-jdk              # version 2:1.17-74
sudo apt install openjdk-11-jdk-headless  # version 11.0.19+7~us1-0ubuntu1~23.04
sudo apt install openjdk-20-jdk-headless  # version 20.0.1+9~us1-0ubuntu1~23.04
sudo apt install openjdk-8-jdk-headless   # version 8u372-ga~us1-0ubuntu1~23.04
sudo apt install ecj                      # version 3.32.0+eclipse4.26-2
sudo apt install openjdk-18-jdk-headless  # version 18.0.2+9-2ubuntu1
sudo apt install openjdk-19-jdk-headless  # version 19.0.2+7-0ubuntu4
sudo apt install openjdk-21-jdk-headless  # version 21~14ea~us1-0ubuntu1
nicholas@mordor:~$ 
nicholas@mordor:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 23.04
Release:    23.04
Codename:   lunar
nicholas@mordor:~$ 

Veja também:

https://stackoverflow.com/q/67469925/4531180

https://snapcraft.io/install/openjdk/ubuntu

command-line
  • 1 1 respostas
  • 47 Views

1 respostas

  • Voted
  1. Best Answer
    Saxtheowl
    2023-06-10T23:25:28+08:002023-06-10T23:25:28+08:00

    Os binários do snap não estão em seu sistema PATH, tente executar os comandos javae javaccom o comando snap completo, como openjdk.javae openjdk.javac, você também pode criar um link simbólico como:

    sudo ln -s /snap/bin/openjdk.java /usr/bin/java
    sudo ln -s /snap/bin/openjdk.javac /usr/bin/javac
    

    Ainda assim, o melhor seria usar um gerenciador de ambiente para Java, como SDKMANoujEnv

    • 2

relate perguntas

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Existe um comando para listar todos os usuários? Também para adicionar, excluir, modificar usuários, no terminal?

    • 9 respostas
  • Marko Smith

    Como excluir um diretório não vazio no Terminal?

    • 4 respostas
  • Marko Smith

    Como descompactar um arquivo zip do Terminal?

    • 9 respostas
  • Marko Smith

    Como instalo um arquivo .deb por meio da linha de comando?

    • 11 respostas
  • Marko Smith

    Como instalo um arquivo .tar.gz (ou .tar.bz2)?

    • 14 respostas
  • Marko Smith

    Como listar todos os pacotes instalados

    • 24 respostas
  • Martin Hope
    Flimm Como posso usar o docker sem sudo? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    led-Zepp Como faço para salvar a saída do terminal em um arquivo? 2014-02-15 11:49:07 +0800 CST
  • Martin Hope
    ubuntu-nerd Como descompactar um arquivo zip do Terminal? 2011-12-11 20:37:54 +0800 CST
  • Martin Hope
    TheXed Como instalo um arquivo .deb por meio da linha de comando? 2011-05-07 09:40:28 +0800 CST
  • Martin Hope
    Ivan Como listar todos os pacotes instalados 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    David Barry Como determino o tamanho total de um diretório (pasta) na linha de comando? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher "Os seguintes pacotes foram retidos:" Por que e como resolvo isso? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford Como os PPAs podem ser removidos? 2010-07-30 01:09:42 +0800 CST

Hot tag

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve