我在HTML页面中运行applet后出现错误,即使我已经签署了所有jar文件

时间:2015-07-11 08:07:37

标签: java html applet vlcj accesscontrolexception

videoplayer和HTML都在其库中包含外部jar文件,它们是jna-3.5.2.jar,platform-3.5.2.jar和vlcj-2.4.1.jar。 视频播放器和HTML页面都在Netbeans的不同项目中,我在两个项目中都包含了上面提到的外部jar文件。

这是videoplayer类的代码。

package Player;

import com.sun.jna.NativeLibrary;
import java.awt.BorderLayout;
import java.awt.Color;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;

public class videoplayer extends javax.swing.JApplet{


public  EmbeddedMediaPlayerComponent mediaPlayerComponent;       
        @Override

    public void init() {
       try{


       NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(),"./src");
       NativeLibrary.addSearchPath(RuntimeUtil.getPluginsDirectoryName(),"./src");

        setBackground(Color.RED);
        setSize(500,500);


        mediaPlayerComponent = new EmbeddedMediaPlayerComponent(); 
       }
       catch(Exception e){
           System.out.println(e);
       }

        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(videoplayer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(videoplayer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(videoplayer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(videoplayer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the applet */
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    initComponents();

                   // JApplet jp=new JApplet();
                    //jp.setLocation(100,100);
                    //jp.setSize(500,500);
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * This method is called from within the init() method to initialize the
     * form. WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jFrame1 = new javax.swing.JFrame();
        jFrame2 = new javax.swing.JFrame();
        jToolBar1 = new javax.swing.JToolBar();
        videopanel = new javax.swing.JPanel();
        lowerpanel = new javax.swing.JPanel();
        Play = new javax.swing.JButton();
        Pause = new javax.swing.JButton();
        Forward = new javax.swing.JButton();
        Backward = new javax.swing.JButton();
        Snapshot = new javax.swing.JButton();
        Volume = new javax.swing.JSlider();
        upperpanel = new javax.swing.JPanel();
        exitfullscreen = new javax.swing.JButton();
        Open = new javax.swing.JButton();
        Stop = new javax.swing.JButton();
        fullscreen = new javax.swing.JButton();

        javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jFrame2Layout = new javax.swing.GroupLayout(jFrame2.getContentPane());
        jFrame2.getContentPane().setLayout(jFrame2Layout);
        jFrame2Layout.setHorizontalGroup(
            jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame2Layout.setVerticalGroup(
            jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        jToolBar1.setRollover(true);

        setBackground(new java.awt.Color(51, 51, 51));
        addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                formPropertyChange(evt);
            }
        });

        videopanel.setBackground(new java.awt.Color(51, 51, 51));

        lowerpanel.setBackground(new java.awt.Color(0, 0, 0));

        Play.setBackground(new java.awt.Color(0, 0, 0));
        Play.setForeground(new java.awt.Color(255, 0, 0));
        Play.setText("Play");
        Play.setToolTipText("");
        Play.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PlayActionPerformed(evt);
            }
        });

        Pause.setBackground(new java.awt.Color(0, 0, 0));
        Pause.setForeground(new java.awt.Color(255, 0, 0));
        Pause.setText("Pause");
        Pause.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PauseActionPerformed(evt);
            }
        });

        Forward.setBackground(new java.awt.Color(0, 0, 0));
        Forward.setForeground(new java.awt.Color(255, 0, 0));
        Forward.setText("Fwd");
        Forward.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ForwardActionPerformed(evt);
            }
        });

        Backward.setBackground(new java.awt.Color(0, 0, 0));
        Backward.setForeground(new java.awt.Color(255, 0, 0));
        Backward.setText("Bwd");
        Backward.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BackwardActionPerformed(evt);
            }
        });

        Snapshot.setBackground(new java.awt.Color(0, 0, 0));
        Snapshot.setForeground(new java.awt.Color(255, 0, 0));
        Snapshot.setText("Snapshot");
        Snapshot.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SnapshotActionPerformed(evt);
            }
        });

        Volume.setBackground(new java.awt.Color(0, 0, 0));
        Volume.setForeground(new java.awt.Color(255, 51, 0));
        Volume.setMajorTickSpacing(2);
        Volume.setMaximum(200);
        Volume.setMinorTickSpacing(1);
        Volume.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                VolumeStateChanged(evt);
            }
        });

        javax.swing.GroupLayout lowerpanelLayout = new javax.swing.GroupLayout(lowerpanel);
        lowerpanel.setLayout(lowerpanelLayout);
        lowerpanelLayout.setHorizontalGroup(
            lowerpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lowerpanelLayout.createSequentialGroup()
                .addComponent(Play, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Pause)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Forward)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Backward)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Snapshot)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Volume, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(308, Short.MAX_VALUE))
        );
        lowerpanelLayout.setVerticalGroup(
            lowerpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(lowerpanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(lowerpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(Volume, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(lowerpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(Play)
                        .addComponent(Pause)
                        .addComponent(Forward)
                        .addComponent(Backward)
                        .addComponent(Snapshot)))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        upperpanel.setBackground(new java.awt.Color(0, 0, 0));
        upperpanel.setForeground(new java.awt.Color(255, 255, 255));

        exitfullscreen.setBackground(new java.awt.Color(0, 0, 0));
        exitfullscreen.setForeground(new java.awt.Color(255, 0, 0));
        exitfullscreen.setText("Exit Full Screen");
        exitfullscreen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitfullscreenActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout upperpanelLayout = new javax.swing.GroupLayout(upperpanel);
        upperpanel.setLayout(upperpanelLayout);
        upperpanelLayout.setHorizontalGroup(
            upperpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, upperpanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(exitfullscreen)
                .addContainerGap())
        );
        upperpanelLayout.setVerticalGroup(
            upperpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, upperpanelLayout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(exitfullscreen))
        );

        Open.setBackground(new java.awt.Color(0, 0, 0));
        Open.setForeground(new java.awt.Color(255, 0, 0));
        Open.setText("Open");
        Open.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OpenActionPerformed(evt);
            }
        });

        Stop.setBackground(new java.awt.Color(0, 0, 0));
        Stop.setForeground(new java.awt.Color(255, 0, 0));
        Stop.setText("Stop");
        Stop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StopActionPerformed(evt);
            }
        });

        fullscreen.setBackground(new java.awt.Color(0, 0, 0));
        fullscreen.setForeground(new java.awt.Color(255, 0, 0));
        fullscreen.setText("Full Screen");
        fullscreen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fullscreenActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout videopanelLayout = new javax.swing.GroupLayout(videopanel);
        videopanel.setLayout(videopanelLayout);
        videopanelLayout.setHorizontalGroup(
            videopanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lowerpanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(videopanelLayout.createSequentialGroup()
                .addGap(2, 2, 2)
                .addComponent(Open)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Stop, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(14, 14, 14)
                .addComponent(fullscreen)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(upperpanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        videopanelLayout.setVerticalGroup(
            videopanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, videopanelLayout.createSequentialGroup()
                .addGroup(videopanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(upperpanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(videopanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(Open)
                        .addComponent(Stop)
                        .addComponent(fullscreen)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 439, Short.MAX_VALUE)
                .addComponent(lowerpanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(videopanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(videopanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
    }// </editor-fold>                        


    private void OpenActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:

     try{
        BorderLayout blmain=new BorderLayout();
        BorderLayout blvideo=new BorderLayout();

        setLayout(blmain);
        videopanel.setLayout(blvideo);

        videopanel.add(mediaPlayerComponent,blmain.CENTER);
        videopanel.add(upperpanel,blmain.NORTH);
        videopanel.add(lowerpanel,blmain.SOUTH);
        videopanel.validate();





        mediaPlayerComponent.getMediaPlayer().prepareMedia(".\\src\\abc.mp4");
        mediaPlayerComponent.getMediaPlayer().setVolume(50);

     }
     catch(Exception e){
         System.out.println(e);
     }
    }                                    



    private void PlayActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        mediaPlayerComponent.getMediaPlayer().play();

    }                                    

    private void PauseActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
        mediaPlayerComponent.getMediaPlayer().pause();

    }                                     

    private void ForwardActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
 mediaPlayerComponent.getMediaPlayer().skip(10000);

    }                                       

    private void BackwardActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        mediaPlayerComponent.getMediaPlayer().skip(-10000);

    }                                        

    private void SnapshotActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        mediaPlayerComponent.getMediaPlayer().setSnapshotDirectory("D:\\");
        mediaPlayerComponent.getMediaPlayer().saveSnapshot();

    }                                        

    private void VolumeStateChanged(javax.swing.event.ChangeEvent evt) {                                    
        // TODO add your handling code here:
        mediaPlayerComponent.getMediaPlayer().setVolume(Volume.getValue());
    }                                   

    private void fullscreenActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:

       videopanel.setSize(1366,650);
        setSize(videopanel.getSize());
        videopanel.revalidate();
        upperpanel.revalidate();
        lowerpanel.revalidate();

    }                                          

    private void StopActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
       mediaPlayerComponent.getMediaPlayer().stop();
       videopanel.remove(mediaPlayerComponent);
    }                                    

    private void formPropertyChange(java.beans.PropertyChangeEvent evt) {                                    
        // TODO add your handling code here:

    }                                   

    private void exitfullscreenActionPerformed(java.awt.event.ActionEvent evt) {                                               
        // TODO add your handling code here:
        setSize(500,500);
        videopanel.setSize(500,500);
    }                                              

/*  */  

    // Variables declaration - do not modify                     
    private javax.swing.JButton Backward;
    private javax.swing.JButton Forward;
    private javax.swing.JButton Open;
    private javax.swing.JButton Pause;
    private javax.swing.JButton Play;
    private javax.swing.JButton Snapshot;
    private javax.swing.JButton Stop;
    private javax.swing.JSlider Volume;
    private javax.swing.JButton exitfullscreen;
    private javax.swing.JButton fullscreen;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JFrame jFrame2;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JPanel lowerpanel;
    private javax.swing.JPanel upperpanel;
    private javax.swing.JPanel videopanel;
    // End of variables declaration                   


}

HTML页面的代码

    <html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
       <applet code ="Player.videoplayer" archive="VLCMediaPlayer.jar" height="500" width ="500"></applet>
    </body>
</html>

当我单独运行applet时,它工作正常,但是当我在HTML页面上运行它并单击其任何按钮时,我收到以下错误:

线程中的异常&#34; AWT-EventQueue-2&#34; java.lang.ExceptionInInitializerError

引起:java.security.AccessControlException:访问被拒绝(&#34; java.util.PropertyPermission&#34;&#34; jna.tmpdir&#34;&#34;阅读&#34;)

0 个答案:

没有答案