gpt4 book ai didi

java - Swing,远程桌面异常

转载 作者:可可西里 更新时间:2023-11-01 09:34:17 27 4
gpt4 key购买 nike

当我使用 Windows 远程桌面连接到运行我的应用程序的 PC 时,我的 Swing 应用程序似乎抛出 ArrayIndexOutOfBounds 异常。知道是什么原因造成的吗?

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 3
at sun.awt.Win32GraphicsEnvironment.getDefaultScreenDevice(Win32GraphicsEnvironment.java:96)
at sun.awt.windows.WWindowPeer.updateGC(WWindowPeer.java:470)
at sun.awt.windows.WWindowPeer.displayChanged(WWindowPeer.java:508)
at sun.awt.windows.WWindowPeer$1.run(WWindowPeer.java:448)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

我在远程访问 PC 时看到过两次,但我从未在其他情况下看到过。因为它全部在 Java 7u25 Sun JDK 内部(查看下面的堆栈跟踪),我什至不确定如何调试它。想法?


其他信息:该机器有两个显卡,每个显卡上有两个显示器端口,Windows 配置为打开所有四个显示器。但是,当我远程进入机器时,显然只有一台显示器。带有开始菜单的监视器(以及包含应用程序的监视器)被 Windows 识别为监视器 #4。

System.getProperties().list(System.out);:

-- listing properties --
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=D:\Program Files\Java\jdk1.7.0_25\jre...
java.vm.version=23.25-b01
java.vm.vendor=Oracle Corporation
java.vendor.url=http://java.oracle.com/
path.separator=;
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg=sun.io
user.script=
user.country=US
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=Service Pack 1
java.vm.specification.name=Java Virtual Machine Specification
user.dir=C:\Code\workspace\client
java.runtime.version=1.7.0_25-b16
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=D:\Program Files\Java\jdk1.7.0_25\jre...
os.arch=amd64
java.io.tmpdir=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
line.separator=

java.vm.specification.vendor=Oracle Corporation
user.variant=
os.name=Windows 7
sun.jnu.encoding=Cp1252
java.library.path=D:\Program Files\Java\jdk1.7.0_25\bin...
java.specification.name=Java Platform API Specification
java.class.version=51.0
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
os.version=6.1
user.home=XXXXXXXXXXXXXXXXXXXXXXXXX
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=Cp1252
java.specification.version=1.7
user.name=XXXXXXXXXXXXXXXXXXXXXXXXX
java.class.path=C:\Code\workspace\client\target\class...
java.vm.specification.version=1.7
sun.arch.data.model=64
java.home=D:\Program Files\Java\jdk1.7.0_25\jre
sun.java.command=com.techemet.client.ClientMain
java.specification.vendor=Oracle Corporation
user.language=en
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode
java.version=1.7.0_25
java.ext.dirs=D:\Program Files\Java\jdk1.7.0_25\jre...
sun.boot.class.path=D:\Program Files\Java\jdk1.7.0_25\jre...
java.vendor=Oracle Corporation
file.separator=\
java.vendor.url.bug=http://bugreport.sun.com/bugreport/
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=windows
sun.cpu.isalist=amd64

最佳答案

Sun 的文档bug JDK-4417798 (您在上一条评论中提到的那个)描述了一种捕获异常的方法。引用文档:

public class BugHandler {
public void handle(Throwable throwable) {
if (e instanceof ArrayIndexOutOfBoundsException) {
StackTraceElement[] trace = e.getStackTrace();

if (trace.length > 1
&& trace[0].getClassName().equals("sun.awt.Win32GraphicsEnvironment")
&& trace[0].getMethodName().equals("getDefaultScreenDevice")) {
your_code_to_handle_exception();
}
}
}
}

它还建议将 -Dsun.java2d.noddraw 选项设置为 true。根据这个other document ,它禁止我们使用 DirectDraw 和 Direct3D。看看是否有帮助。

您还可以尝试强制应用程序在特定屏幕上运行,而不是依赖 Java 对图形环境的自动检测。在 API documentation 中有一个使用 GraphicsDevice 类 的相关示例.

关于java - Swing,远程桌面异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19361424/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com