我目前正在编写一个小型终端应用程序,使用我发现的一个非常酷的 Java 库:Lanterna。它允许我使用与 Swing 类似的概念编写类似 ncurses 的应用程序。
由于该应用程序的最终目标是在服务器上运行,因此我在 Vagrant ubuntu 机器上对其进行了测试。不幸的是,在每次启动时,我都会收到以下错误:
vagrant@precise64:~/myProject/target$ java -jar myProject-1.1.0-SNAPSHOT.jar -Djava.awt.headless=true
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/jdk1.6.0_37/jre/lib/amd64/xawt/libmawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1724)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1605)
at java.awt.Toolkit.<clinit>(Toolkit.java:1627)
at java.awt.Font.<clinit>(Font.java:210)
at com.googlecode.lanterna.terminal.swing.TerminalAppearance.createDefaultNormalFont(TerminalAppearance.java:46)
at com.googlecode.lanterna.terminal.swing.TerminalAppearance.<clinit>(TerminalAppearance.java:33)
at com.googlecode.lanterna.terminal.swing.SwingTerminal.<init>(SwingTerminal.java:77)
at com.googlecode.lanterna.TerminalFacade.createSwingTerminal(TerminalFacade.java:115)
at com.googlecode.lanterna.TerminalFacade.createSwingTerminal(TerminalFacade.java:104)
at com.googlecode.lanterna.TerminalFacade.createTerminal(TerminalFacade.java:95)
at com.googlecode.lanterna.TerminalFacade.createTerminal(TerminalFacade.java:65)
at com.googlecode.lanterna.TerminalFacade.createTerminal(TerminalFacade.java:54)
at com.googlecode.lanterna.TerminalFacade.createScreen(TerminalFacade.java:247)
at com.googlecode.lanterna.TerminalFacade.createGUIScreen(TerminalFacade.java:261)
我猜我的 Java 安装有问题,它来自使用此配置的Chef solo Java recipe
chef.json = {
:java => {
:install_flavor => "oracle",
:oracle => {
"accept_oracle_download_terms" => true
}
},
:maven => {
:version => '3',
:setup_bin => 'true'
}
}
但是我该如何解决呢?