在Windows 11 中使用 VMware 安装好ubuntu 22.04之后,打开console,先更新源:
sudo apt update
然后升级
sudo apt upgrade -y
然后安装jdk ,先看有哪些jdk版本
sudo apt-cache search jdk
会输出如下:
default-jdk - Standard Java or Java compatible Development Kit
default-jdk-doc - Standard Java or Java compatible Development Kit (documentation)
default-jdk-headless - Standard Java or Java compatible Development Kit (headless)
default-jre - Standard Java or Java compatible Runtime
default-jre-headless - Standard Java or Java compatible Runtime (headless)
openjdk-11-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-11-doc - OpenJDK Development Kit (JDK) documentation
openjdk-11-jdk - OpenJDK Development Kit (JDK)
openjdk-11-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-11-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-11-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-11-source - OpenJDK Development Kit (JDK) source files
crypto-policies - unify the crypto policies used by different applications and libraries
fakeroot-ng - Gives a fake root environment
golang-github-jdkato-prose-dev - Golang library for text processing
golang-github-jdkato-syllables-dev - Go syllable counter
japitools - Java API compatibility testing tools
jattach - JVM Dynamic Attach utility all in one jmap jstack jcmd jinfo
java3ds-fileloader - Java3D 3DS File Loader
jtreg - Regression Test Harness for the OpenJDK platform
jtreg6 - Regression Test Harness for the OpenJDK platform
libanimal-sniffer-java - JDK/API verification tools
libanimal-sniffer-java-doc - Documentation for Animal Sniffer
libassertj-core-java - Fluent assertions for Java
libbackport9-java - Collection of backports and utilities for apps and libraries
libcava-java - Libraries and tools for blockchain and decentralized software
libcolt-free-java - scalable scientific and technical computing in Java
libcolt-free-java-doc - scalable scientific and technical computing in Java (doc)
libcommons-collections3-java - Apache Commons Collections - Extended Collections API for Java
libcommons-collections4-java - Apache Commons Collections - Extended Collections API for Java
libcommons-collections4-java-doc - Documentation for Commons Collections 4
libcommons-lang-java - Commons Lang - an extension of the java.lang package
libcommons-lang-java-doc - Documentation for Commons Lang - an extension of the java.lang package
libcommons-math-java - Java lightweight mathematics and statistics components
libcommons-math-java-doc - Java lightweight mathematics and statistics components - documentation
libcommons-math3-java - Java lightweight mathematics and statistics components
libcommons-math3-java-doc - Java lightweight mathematics and statistics components - documentation
libeclipse-collections-java - Eclipse Collections - comprehensive collections library for Java
libgkl-java - Java library to manipulate SAM and BAM files
libgkl-jni - native libraries of Java library to manipulate SAM and BAM files
libgrpc-java - Java gRPC implementation, HTTP/2 based RPC
libgs-collections-java - Goldman Sachs Collections
libhawtbuf-java - HawtBuf rich byte buffer library
libhessian-java - Java implementation of a binary protocol for web services
libhessian-java-doc - Documentation for libhessian-java
libhibernate-commons-annotations-java - Hibernate Commons Annotations
libhsdis0-fcml - HotSpot disassembler plugin using FCML
libhtsjdk-java - Java API for high-throughput sequencing data (HTS) formats
libhtsjdk-java-doc - Documentation for the java HTSJDK library
libicu4j-4.4-java - Library for Unicode support and internationalization
libicu4j-java - Library for Unicode support and internationalization
libintellij-java-compatibility-java - Classes from JDK8 excluded from JDK9
libitext1-java - Java Library to generate PDF on the Fly
libjackson2-jr-java - JSON library for Java -- standalone data-binding module
libjax-maven-plugin - Using the xjc goal with OpenJDK 11+
libjboss-logmanager-java - implementation of java.util.logging.LogManager
libjctools-java - Java Concurrency Tools for the JVM
libjheaps-java - Java library with various heap implementations
libjodd-java - Java utility library and set of frameworks
libjws-api-java - Java EE Web Services Metadata API (JSR 181)
libjxp-java - Java template engine/script processor
libkryo-serializers-java - Kryo serializers
libmaven-enforcer-plugin-java - Maven build rule execution framework
libmodulator-java - Java small shim library that wraps Java 9 APIs and exposes them to recent JDKs
libnb-javaparser-java - Parser for the Java language which is good for use in tools
libpicocontainer1-java - Java library implementing the Dependency Injection pattern
libpracticalxml-java - practical XML handling routines
libreoffice - office productivity suite (metapackage)
libslf4j-java - Simple Logging Facade for Java
libthreeten-extra-java - Additional functionality that enhances JSR-310 dates and times
libtrove-intellij-java - high performance collections for java
libtrove-java - high performance collections for java
libtrove-java-doc - high performance collections for java
libtrove3-java - high performance collections for java
libtrove3-java-doc - high performance collections for java
libunsafe-fences-java - wrapper library around the Java 8 fences API
libunsafe-mock-java - Java library providing backported sun.misc.Unsafe class from JDK 8
libvisualvm-jni - All-in-One Java Troubleshooting Tool (JNI libraries)
mmake - Makefile generator for Java programs
openjdk-11-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-11-jre-dcevm - Alternative VM for OpenJDK 11 with enhanced class redefinition
openjdk-11-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-17-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-17-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-17-doc - OpenJDK Development Kit (JDK) documentation
openjdk-17-jdk - OpenJDK Development Kit (JDK)
openjdk-17-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-17-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-17-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-17-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-17-source - OpenJDK Development Kit (JDK) source files
openjdk-18-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-18-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-18-doc - OpenJDK Development Kit (JDK) documentation
openjdk-18-jdk - OpenJDK Development Kit (JDK)
openjdk-18-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-18-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-18-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-18-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-18-source - OpenJDK Development Kit (JDK) source files
openjdk-8-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-8-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-8-doc - OpenJDK Development Kit (JDK) documentation
openjdk-8-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-8-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-8-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
openjdk-8-source - OpenJDK Development Kit (JDK) source files
substance - cross-platform look & feel for Swing applications
substance-doc - cross-platform look & feel for Swing applications - documentation
substance-flamingo - Substance Flamingo plugin
substance-flamingo-doc - Substance Flamingo plugin (documentation)
testng - testing framework for Java
uwsgi-app-integration-plugins - plugins for integration of uWSGI and application
uwsgi-plugin-jvm-openjdk-11 - Java plugin for uWSGI (OpenJDK 11)
uwsgi-plugin-jwsgi-openjdk-11 - JWSGI plugin for uWSGI (OpenJDK 11)
uwsgi-plugin-ring-openjdk-11 - Closure/Ring plugin for uWSGI (OpenJDK 11)
uwsgi-plugin-servlet-openjdk-11 - JWSGI plugin for uWSGI (OpenJDK 11)
visualvm - All-in-One Java Troubleshooting Tool
java-package - Utility for creating Java Debian packages
openjdk-8-jdk - OpenJDK Development Kit (JDK)
openjdk-8-jdk-headless - OpenJDK Development Kit (JDK) (headless)
输出的第一例表示 package name,然后根据你的需求来选择哪个版本来安装。
这里我们选择安装 openjdk-11-jdk :
sudo apt install -y openjdk-11-jdk
成功之后执行:
java -version
如果输出:
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)
则安装成功 。