简体   繁体   中英

How to debug java applet

Im not very familiour with Java nor Java applets but I have to fix this issue.

Ever since JRE 7 Update 21 the applet is throwing eceptions in all browsers.

在此处输入图片说明

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).

So the applet is used as a JAR file in .NET application. It is called as javascript with some code:

<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.

Now I want to debug in order to find the reason for this exception. I have eclipse, the source code and an JAR export.

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.

Please can some one point me to the solution - how can i debug this in eclipse?

In Eclipse, navigate to your Applet class, and then click Run in Eclipse menu, then Debug As and Java Applet . Eclipse will launch your applet in debug mode.

The java console will give you a full stack trace on any exceptions your applet is throwing. You can enable it by following the instructions on the linked Oracle doc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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