Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java阻止我运行本地Java小程序_Java_Security_Applet - Fatal编程技术网

Java阻止我运行本地Java小程序

Java阻止我运行本地Java小程序,java,security,applet,Java,Security,Applet,我有一个简单的小程序,我想在本地运行,但是java阻止了它 小程序代码如下所示: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class FollowMe extends JApplet { private int xCoord = 100, yCoord = 100; /** * init method */ public void init() { setBackgroun

我有一个简单的小程序,我想在本地运行,但是java阻止了它

小程序代码如下所示:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class FollowMe extends JApplet
{
private int xCoord = 100, yCoord = 100;

/**
 * init method
 */

public void init()
{
    setBackground(Color.WHITE);
    addMouseMotionListener(new MyMouseMotionListener());
}

/**
 * paint method
 */

public void paint(Graphics g)
{
    // Call the base class paint method.
    super.paint(g);

    // Draw the string at the current mouse location.
    g.drawString("Hello", xCoord, yCoord);
}

/**
 * Private inner class that handles mouse
 * motion events.
 */

private class MyMouseMotionListener implements MouseMotionListener
{
    /**
     * mouseMoved method
     */

    public void mouseMoved(MouseEvent e)
    {
        // Get the mouse pointer's X and Y coordinates.
        xCoord = e.getX();
        yCoord = e.getY();

        // Force the paint method to execute.
        repaint();
    }

    /**
     * Unused mouseDragged method
     */

    public void mouseDragged(MouseEvent e)
    {
    }
}
}
当然,我在HTML文件中引用了类文件。 我已转到JAVA安全设置并添加了以下异常:

"file:///D:/Downloads/AppletsExamples%281%29/01%20-%20FollowMe%20Applet/FollowMe.html“

您可以看到,这是我在firefox中打开的访问Html文件的路径。
但是,JAVA仍然会阻止小程序。这太令人沮丧了,我在别处找不到任何帮助。

为什么要编写小程序?如果是老师指定的,请参考。@VinceEmigh不,我没有签名。@AndrewThompson是的,是我的老师指定的。一旦我完成了课程,我会把它交给他!我自己找到了一个解决方案,我设法使用CMD中的appletviewer运行小程序,这足以满足我的需要。谢谢你的回复。