无法在 WSL 2 中的 Ubuntu 22.x 中运行 VisualVM

问题描述 投票:0回答:1

我使用的是 Windows 11。我已经安装了 Windows 版本的 VisualVM,并且能够完美运行它,没有任何问题。 我想尝试Linux风格。我设置了 sdkman、java 和 maven。但由于某种原因我无法成功运行 VisualVM。

我认为问题在于

libXtst.so
在 Ubuntu 22 中不可用。Ubuntu 使用所有小写字母,或者我听说过。但我无法进一步排除故障并解决问题。我尝试了所有 Java 8、17 和 21。我什至手动设置了标志:
visualvm --jdkhome=/home/ahroo/.sdkman/candidates/java/17.0.9-amzn

我在下面添加了版本详细信息。

ahroo@AhrooranR:/mnt/c/Users/AhrooranRavindran$ sdk default java
17.0.9-amzn   21.0.1-amzn   8.0.392-amzn
ahroo@AhrooranR:/mnt/c/Users/AhrooranRavindran$ java -version
openjdk version "21.0.1" 2023-10-17 LTS
OpenJDK Runtime Environment Corretto-21.0.1.12.1 (build 21.0.1+12-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.1.12.1 (build 21.0.1+12-LTS, mixed mode, sharing)
ahroo@AhrooranR:/mnt/c/Users/AhrooranRavindran$ mvn -v
Apache Maven 3.9.4 (dfbb324ad4a7c8fb0bf182e6d91b0ae20e3d2dd9)
Maven home: /mnt/c/AHROO/programs/apache-maven-3.9.2
Java version: 21.0.1, vendor: Amazon.com Inc., runtime: /home/ahroo/.sdkman/candidates/java/21.0.1-amzn
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.15.133.1-microsoft-standard-wsl2", arch: "amd64", family: "unix"
ahroo@AhrooranR:/mnt/c/Users/AhrooranRavindran$ sdk default visualvm 2.1.7
setting visualvm 2.1.7 as the default version for all shells.
ahroo@AhrooranR:/mnt/c/Users/AhrooranRavindran$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
ahroo@AhrooranR:/mnt/c/Users/AhrooranRavindran$ visualvm
java.lang.UnsatisfiedLinkError: /home/ahroo/.sdkman/candidates/java/21.0.1-amzn/lib/libawt_xawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
        at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
        at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418)
        at java.base/java.lang.Runtime.load0(Runtime.java:852)
        at java.base/java.lang.System.load(System.java:2021)
        at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
        at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
        at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:259)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:249)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2427)
        at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916)
        at java.base/java.lang.System.loadLibrary(System.java:2059)
        at java.desktop/sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:67)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
        at java.desktop/sun.awt.X11GraphicsEnvironment.initStatic(X11GraphicsEnvironment.java:64)
        at java.desktop/sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:59)
        at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:37)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:93)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:84)
        at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:106)
        at org.netbeans.core.startup.Main.start(Main.java:245)
        at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
        at java.base/java.lang.Thread.run(Thread.java:1583)

我用控制台输出运行了可视化。也许这会有所帮助:

ahroo@AhrooranR:/mnt/c/Users/AhrooranRavindran$ visualvm -J-Dnetbeans.logger.console=true
java.lang.UnsatisfiedLinkError: /home/ahroo/.sdkman/candidates/java/21.0.1-amzn/lib/libawt_xawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
        at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
        at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418)
        at java.base/java.lang.Runtime.load0(Runtime.java:852)
        at java.base/java.lang.System.load(System.java:2021)
        at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
        at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
        at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:259)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:249)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2427)
        at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916)
        at java.base/java.lang.System.loadLibrary(System.java:2059)
        at java.desktop/sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:67)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
        at java.desktop/sun.awt.X11GraphicsEnvironment.initStatic(X11GraphicsEnvironment.java:64)
        at java.desktop/sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:59)
        at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:37)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:93)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:84)
        at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:106)
        at org.netbeans.core.startup.Main.start(Main.java:245)
        at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
        at java.base/java.lang.Thread.run(Thread.java:1583)
-------------------------------------------------------------------------------
>Log Session: Sunday, January 7, 2024, 6:02:00 PM India Standard Time
>System Info:
  Product Version         = VisualVM 2.1.7
  Operating System        = Linux version 5.15.133.1-microsoft-standard-WSL2 running on amd64
  Java; VM; Vendor        = 21.0.1; OpenJDK 64-Bit Server VM 21.0.1+12-LTS; Amazon.com Inc.
  Runtime                 = OpenJDK Runtime Environment 21.0.1+12-LTS
  Java Home               = /home/ahroo/.sdkman/candidates/java/21.0.1-amzn
  System Locale; Encoding = en (visualvm); UTF-8
  Home Directory          = /home/ahroo
  Current Directory       = /mnt/c/Users/AhrooranRavindran
  User Directory          = /home/ahroo/.visualvm/2.1.7
  Cache Directory         = /home/ahroo/.cache/visualvm/2.1.7
  Installation            = /home/ahroo/.sdkman/candidates/visualvm/current/visualvm
                            /home/ahroo/.sdkman/candidates/visualvm/current/platform
  Boot & Ext. Classpath   =
  Application Classpath   = /home/ahroo/.sdkman/candidates/visualvm/current/platform/lib/boot.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/lib/org-openide-modules.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/lib/org-openide-util-lookup.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/lib/org-openide-util-ui.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/lib/org-openide-util.jar
  Startup Classpath       = /home/ahroo/.sdkman/candidates/visualvm/current/platform/core/org-openide-filesystems.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/core/core-base.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/core/org-netbeans-libs-asm.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/core/core.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/core/asm-commons-9.2.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/core/asm-tree-9.2.jar:/home/ahroo/.sdkman/candidates/visualvm/current/platform/core/asm-9.2.jar:/home/ahroo/.sdkman/candidates/visualvm/current/visualvm/core/org-graalvm-visualvm-modules-startup.jar:/home/ahroo/.sdkman/candidates/visualvm/current/visualvm/core/locale/core_visualvm.jar
-------------------------------------------------------------------------------
java wsl-2 ubuntu-22.04 visualvm sdkman
1个回答
0
投票

我认为问题在于

libXtst.so
在 Ubuntu 22 中不可用。

在 Ubuntu 22.04.3 LTS 系统上,按照 How do I find the package that Provides a file? 中的建议报告,

libXtst.so
libxtst6:amd64
包提供:

$ apt-file find libXtst.so
libxtst-dev: /usr/lib/x86_64-linux-gnu/libXtst.so
libxtst6: /usr/lib/x86_64-linux-gnu/libXtst.so.6
libxtst6: /usr/lib/x86_64-linux-gnu/libXtst.so.6.1.0

建议尝试

sudo apt install libxtst6
安装该软件包,看看是否:

  1. 这允许
    visualvm
    运行。
  2. 或者更改错误消息以报告不同的缺少依赖共享库。在这种情况下,上面使用
    apt-file find
    搜索提供特定共享库的包的示例应该允许您找到并安装提供共享库的包。
© www.soinside.com 2019 - 2024. All rights reserved.