0

Both the videoplayer and HTML contains external jar files in its library which are jna-3.5.2.jar,platform-3.5.2.jar and vlcj-2.4.1.jar. Both videoplayer and HTML page are in different projects in Netbeans and I have included the external jar files mentioned above in both the projects.

This is the code of videoplayer class.

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                   


}

The code of HTML page

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

When I run the applet separately it works fine but when I run it on the HTML page and click on any of its button I get the following error :

Exception in thread "AWT-EventQueue-2" java.lang.ExceptionInInitializerError

Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "jna.tmpdir" "read")

Aditya
  • 1
  • 2
  • 1) Be sure the [Java Console](http://www.java.com/en/download/help/javaconsole.xml) is configured to show. If there is no output at the default level, raise the level and try it again. 2) Please learn common Java nomenclature (naming conventions - e.g. `EachWordUpperCaseClass`, `firstWordLowerCaseMethod()`, `firstWordLowerCaseAttribute` unless it is an `UPPER_CASE_CONSTANT`) and use it consistently. – Andrew Thompson Jul 11 '15 at 08:52
  • @AndrewThompson Hey thanks for your advice.I will surely keep these in mind next time I write a code.Can you help me with this error?I signed all the jar files even after that I am getting this error Exception in thread "AWT-EventQueue-2" java.lang.ExceptionInInitializerError Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "jna.tmpdir" "read") – Aditya Jul 11 '15 at 10:18
  • Don't post code or stack traces in comments where it is virtually unreadable. Instead [edit the question](http://stackoverflow.com/posts/31354938/edit)! – Andrew Thompson Jul 11 '15 at 10:22
  • @AndrewThompson Ok I really don't have an idea what to post where as this is my first day on this website.I have edited the question.Please help now if you can. – Aditya Jul 11 '15 at 10:33
  • The edit to the title is an improvement, as is the adding of the stack trace. But I meant *add it to* the existing information (I.E. the source code and HTML) rather than *replace* the existing information. But basically, something in the Jar(s) is not trusted. As an aside, you mention Jars (plural) yet the applet element only mentions `VLCMediaPlayer.jar` (one Jar). Is it one, or more than one? – Andrew Thompson Jul 11 '15 at 10:45
  • @AndrewThompson There are just some external jar files jna,platform and vlcj except for that no. – Aditya Jul 11 '15 at 10:50
  • *"There are just.."* Where is that edit? I won't be spending further time on this until you've fixed the damage to the question that I mentioned in the last comment. *"this is my first day on this website."* That's a good time to learn this sort of stuff (how to use the site). – Andrew Thompson Jul 11 '15 at 10:55
  • @AndrewThompson I have provided all the information in the question now. – Aditya Jul 11 '15 at 11:41
  • *"There are just some external jar files jna,platform and vlcj except for that no."* Well, if they are 'external' to the class-path of the applet (read 'all the Jars mentioned in the `archive` attribute) the only way that could work for the clients is to have those natives and Jars *already installed in their system.* So, basically it won't work (for the vast majority of visitors). So first we need to figure out everything that actually **needs** to be in the class-path, then look at each of those Jars to discover what the problem is. BTW - you mention they are signed, but did you .. – Andrew Thompson Jul 11 '15 at 11:50
  • .. (sorry, hit the character limit for a comment there) ..use a **valid code signing certificate (issued by a *Certification Authority*)?** – Andrew Thompson Jul 11 '15 at 11:52
  • Oh, and another thing. Natives were very hard to deploy for applets before [Java Web Start](http://stackoverflow.com/tags/java-web-start/info) based launch was implemented (that applet element does not use JWS). Also, why is this an applet? Or more specifically, why does a video based app. need to be *embedded in a web page?* – Andrew Thompson Jul 11 '15 at 11:56
  • @AndrewThompson This is really the first time I have made an applet that can play a video and I was trying to add that to a web page and see if it works.And about the earlier question I didn't knew anything about signing jar files I just applied the method explained in this answer [link](http://stackoverflow.com/a/17187923/5105317) – Aditya Jul 11 '15 at 11:58
  • *"This is really the first time I have made an applet.."* Applets are a complete PITA to develop *or* maintain. Chrome is set to completely drop support for them. ..And you have bitten off a huge mouthful to try and combine natives with your *first applet.* *"..I was trying to add that to a web page and see if it works."* If you want to offer software from the web, I point you back to Java Web Start (mentioned and info. linked above). JWS can launch applets or **desktop apps.** from a link on a web page. .. – Andrew Thompson Jul 11 '15 at 12:02
  • .. Side step the applet completely to avoid half the problems you'll likely face in getting this deployed. – Andrew Thompson Jul 11 '15 at 12:03
  • 1
    @AndrewThompson Okay I will start to learn about JWS from today onwards. Thank you for all your guidance Sir. – Aditya Jul 11 '15 at 12:09

0 Answers0