简体   繁体   English

如何调试Java小程序

[英]How to debug java applet

Im not very familiour with Java nor Java applets but I have to fix this issue. 我不太熟悉Java或Java小程序,但我必须解决此问题。

Ever since JRE 7 Update 21 the applet is throwing eceptions in all browsers. 从JRE 7 Update 21开始,小程序就在所有浏览器中抛出异常。

在此处输入图片说明

I need to debug the app, because the error gives no clues whatsoever (the application was running for years now, its after latest JRE update that the clients cant use it anymore). 我需要调试该应用程序,因为该错误没有任何提示(该应用程序已运行多年,在最新的JRE更新之后,客户端不再可以使用它)。

So the applet is used as a JAR file in .NET application. 因此,该小程序在.NET应用程序中用作JAR文件。 It is called as javascript with some code: 它被称为javascript,带有一些代码:

<html>
<head>
    <script type="text/javascript">
        var i = 0;
        var path = "\\\\\\\\reaktorm\\\\Outgoing\\\\test";
        var ext = ".tif";
        var fullPath = "";

        function nextImage() {
            if (i==2) {
                alert("There is no next image in collection!");
            } else {
                i++;
                displayImage();
            }
        }

        function previousImage() {
            if (i<1) {
                alert("There is no previous image in collection!");
            } else {
                i--;
                displayImage();
            }
        }

        function displayImage() {
            //fullPath= path + (i<10?"0"+i:i) + ext;
            fullPath= path + ext;
            alert(fullPath);
            document.webViewer.display(fullPath);
        }
    </script>
</head>
<body>
    <div style="width:100%; height:100%;">
        <applet name="webviewer" archive="..\webviewer.jar" code="my.webviewer.WebViewerApplet.class" width="100%" height="100%">
            <param name="java_arguments" value="-Xmx512m">
            <param name="image_source" value="C:\test\test.tif">
        </applet>
    </div>
    <form id="testForm" name="testForm" style="display:block">
        <input type="button" onClick="previousImage();" value="previous" />
        <input type="button" onClick="nextImage();" value="next" />
    </form>
</body>
</html>

So if I put this in html file and open it in a browser, i get the upper RuntimeException. 因此,如果我将其放在html文件中并在浏览器中打开它,则会得到上面的RuntimeException。

Now I want to debug in order to find the reason for this exception. 现在,我想调试以便找到此异常的原因。 I have eclipse, the source code and an JAR export. 我有日食,源代码和JAR导出。

I have tried remote debug by launching: 我已经尝试通过启动远程调试:

java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar webviewer.jar

Then i tried to connect to that using "Remote Java Application" under Debug options in eclipse by connection to locahost:5005, but i get connection refused. 然后我尝试通过与locahost:5005的连接使用Eclipse中Debug选项下的“ Remote Java Application”连接到该服务器,但是我被拒绝连接。

Please can some one point me to the solution - how can i debug this in eclipse? 请有人指出解决方案-如何在Eclipse中调试呢?

In Eclipse, navigate to your Applet class, and then click Run in Eclipse menu, then Debug As and Java Applet . 在Eclipse中,导航到Applet类,然后在Eclipse菜单中单击Run ,然后单击Debug AsJava Applet Eclipse will launch your applet in debug mode. Eclipse将以调试模式启动您的applet。

The java console will give you a full stack trace on any exceptions your applet is throwing. Java控制台将为您的applet抛出的所有异常提供完整的堆栈跟踪。 You can enable it by following the instructions on the linked Oracle doc. 您可以按照链接的Oracle文档上的说明启用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM