无法加载系统光标:Centos 7 Java 中的 CopyDrop.32x32 异常
Cannot load system cursor: CopyDrop.32x32 exception in Java on Centos 7
我在 Centos 7 上安装了 netbeans 8.2。
我收到这个错误:
java.lang.RuntimeException: failed to load system cursor: DnD.Cursor.CopyDrop : cannot load system cursor: CopyDrop.32x32
at java.awt.dnd.DragSource.load(DragSource.java:135)
at java.awt.dnd.DragSource.<clinit>(DragSource.java:148)
Java版本:
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)
我该如何解决这个问题?
事实证明它与 Unity-Mir 中报告的错误有关:Java applications are missing X11 resources - XQueryBestCursor return 0,0。
根据评论,JDK 版本和旧的 XMir(不再受支持)是造成这种情况的原因。
无论如何,它已被最后的 XMir 版本修复。
This would be a bug in Java, where it is unable to deal with the Xorg
software cursor. Which is a problem unrelated to Mir really. Mir just
puts X in a (valid) mode where the bug is triggered.
Although, we could work around the Java bug by implementing full
hardware cursor support in XMir...
和
XMir 1.0 (the old Xorg extension) is now deprecated and is not being
maintained or fixed. It is replaced by the new 'Xmir' binary (package
'xmir') introduced in Ubuntu 15.10 wily.
和
Note: The new Xmir uses the hardware cursor (where available on
desktop). So if this bug still exists at all, it would only be on
mobile (Android Mir platform).
您应该考虑升级到 "new" 版本。
我找到了解决方案。
1- 编辑以下文件:
nano /etc/default/grub
2- 将 rhgb quiet
替换为 nomodeset
.
3- 运行 在终端 grub2-mkconfig -o /boot/grub2/grub.cfg
4- 重启。
其实这并不能解决问题。只能无视了。
我在 virtualbox 的 Kali 上遇到了问题。
如果您的 OS 在 virtualbox 中,独奏将关闭 OS。
然后在机器 -> 设置 -> 显示下关闭“启用 3D 加速”。
开始你的OS并享受吧!
似乎这个错误已经用 java 8u152 b05 解决了。
以下代码通过 8u152,但使用 Java 8u131:
抛出上述异常
public static void main(String[] args) {
DragSource.getDefaultDragSource();
}
目前 8u152 在 "JDK 8 Updates Early-Access Builds" 中可用:
http://jdk.java.net/8/
我的 Java 代码在 JTree 中使用拖放,从 CentOS 6 升级到 CentOS 7 后它会损坏。相同的硬件,相同的 OpenJDK,相同的 Java 代码,但图形驱动程序不同。内核命令行设置 "nomodeset" 的解决方法有所帮助,但会导致图形效果不佳和闪烁。
这是一个纯粹的 Java 解决方法:
//workaround for used Drag&Drop cursors which are unsupported by graphics driver
public static void initUnsupportedCursors() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
{
String cursors[] = new String[]{
"DnD.Cursor.CopyDrop",
"DnD.Cursor.MoveDrop",
"DnD.Cursor.LinkDrop",
"DnD.Cursor.CopyNoDrop",
"DnD.Cursor.MoveNoDrop",
"DnD.Cursor.LinkNoDrop"
};
List <String> unsupportedCursors = new ArrayList <String>();
for (String c : cursors)
{
try
{
if (Toolkit.getDefaultToolkit().getDesktopProperty(c) == null)
{
throw new Exception("Can't find cursor " + c);
}
}
catch (Exception e)
{
unsupportedCursors.add(c);
}
}
if (!unsupportedCursors.isEmpty())
{
Field propsFiled = Toolkit.class.getDeclaredField("desktopProperties");
propsFiled.setAccessible(true);
Map props = (Map) propsFiled.get(Toolkit.getDefaultToolkit());
for (String unsupportedCursor : unsupportedCursors)
{
System.out.println("Replacing unsupported " + unsupportedCursor + " by " + Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
props.put(unsupportedCursor, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
}
我在 Centos 7 上安装了 netbeans 8.2。
我收到这个错误:
java.lang.RuntimeException: failed to load system cursor: DnD.Cursor.CopyDrop : cannot load system cursor: CopyDrop.32x32
at java.awt.dnd.DragSource.load(DragSource.java:135)
at java.awt.dnd.DragSource.<clinit>(DragSource.java:148)
Java版本:
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)
我该如何解决这个问题?
事实证明它与 Unity-Mir 中报告的错误有关:Java applications are missing X11 resources - XQueryBestCursor return 0,0。
根据评论,JDK 版本和旧的 XMir(不再受支持)是造成这种情况的原因。 无论如何,它已被最后的 XMir 版本修复。
This would be a bug in Java, where it is unable to deal with the Xorg software cursor. Which is a problem unrelated to Mir really. Mir just puts X in a (valid) mode where the bug is triggered.
Although, we could work around the Java bug by implementing full hardware cursor support in XMir...
和
XMir 1.0 (the old Xorg extension) is now deprecated and is not being maintained or fixed. It is replaced by the new 'Xmir' binary (package 'xmir') introduced in Ubuntu 15.10 wily.
和
Note: The new Xmir uses the hardware cursor (where available on desktop). So if this bug still exists at all, it would only be on mobile (Android Mir platform).
您应该考虑升级到 "new" 版本。
我找到了解决方案。
1- 编辑以下文件:
nano /etc/default/grub
2- 将 rhgb quiet
替换为 nomodeset
.
3- 运行 在终端 grub2-mkconfig -o /boot/grub2/grub.cfg
4- 重启。
其实这并不能解决问题。只能无视了。
我在 virtualbox 的 Kali 上遇到了问题。
如果您的 OS 在 virtualbox 中,独奏将关闭 OS。
然后在机器 -> 设置 -> 显示下关闭“启用 3D 加速”。
开始你的OS并享受吧!
似乎这个错误已经用 java 8u152 b05 解决了。 以下代码通过 8u152,但使用 Java 8u131:
抛出上述异常public static void main(String[] args) {
DragSource.getDefaultDragSource();
}
目前 8u152 在 "JDK 8 Updates Early-Access Builds" 中可用: http://jdk.java.net/8/
我的 Java 代码在 JTree 中使用拖放,从 CentOS 6 升级到 CentOS 7 后它会损坏。相同的硬件,相同的 OpenJDK,相同的 Java 代码,但图形驱动程序不同。内核命令行设置 "nomodeset" 的解决方法有所帮助,但会导致图形效果不佳和闪烁。 这是一个纯粹的 Java 解决方法:
//workaround for used Drag&Drop cursors which are unsupported by graphics driver
public static void initUnsupportedCursors() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
{
String cursors[] = new String[]{
"DnD.Cursor.CopyDrop",
"DnD.Cursor.MoveDrop",
"DnD.Cursor.LinkDrop",
"DnD.Cursor.CopyNoDrop",
"DnD.Cursor.MoveNoDrop",
"DnD.Cursor.LinkNoDrop"
};
List <String> unsupportedCursors = new ArrayList <String>();
for (String c : cursors)
{
try
{
if (Toolkit.getDefaultToolkit().getDesktopProperty(c) == null)
{
throw new Exception("Can't find cursor " + c);
}
}
catch (Exception e)
{
unsupportedCursors.add(c);
}
}
if (!unsupportedCursors.isEmpty())
{
Field propsFiled = Toolkit.class.getDeclaredField("desktopProperties");
propsFiled.setAccessible(true);
Map props = (Map) propsFiled.get(Toolkit.getDefaultToolkit());
for (String unsupportedCursor : unsupportedCursors)
{
System.out.println("Replacing unsupported " + unsupportedCursor + " by " + Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
props.put(unsupportedCursor, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
}