Working with sockets with applets

Hello, I am working in my account on a web server, and I am trying to develop a chat using applets. My program works great on the command line, but the applets cannot create a socket because of a SocketPermission problem. I have read about this problem a lot, and I found that applets will only create a socket with the server the applet originates from. I have still not had any success in allowing my applet to create a socket to connect to a server.
I would appreciate any advice concerning this problem!
Thanks so much!
Christina

If you are calling the HTML page containing the Applet as http://localhost then the Applet has to open a socket back to local host.
Make sure you call the applet using the full ip address of the where the web server is running. This should match the socket ip address you are trying to open inside the Applet.

Similar Messages

  • How to make pack200 work with applet tag ?

    Hello All,
    Sorry for the cross-post.
    I tired getting the advise on java.net forum but with no success. Can someone here please help with this or direct me to right direction.
    I am trying to use the pack200 compressed jars for my Object/Applet tag, but not sure how to go about using it.
    I have followed the instructions for jarsigned pack200 jars.
    http://java.sun.com/j2se/1.5.0/docs/guide/deployme.../deployment-guide/pack200.html
    But now how do i use them in my Object tag, what should i name the files in my cache_archive parameter :
    example:
    something like :
    <PARAM NAME = CACHE_ARCHIVE VALUE = "final.jar" />
    or :
    <PARAM NAME = CACHE_ARCHIVE VALUE = "final.jar.pack.gz" />
    renaming : final.jar.pack.gz --> final.jar ??
    I tried both the above options but none of them works.
    network: Wrote URL http://myserver.net/Stream/lib/final.jar to File C:\Documents and Settings\I025204\Application Data\Sun\Java\Deployment\cache\6.0\60\366763c-2a096009-temp
    java.util.zip.ZipException: ZIP file must have at least one entry
    at java.util.zip.ZipOutputStream.finish(Unknown Source)
    at java.util.zip.DeflaterOutputStream.close(Unknown Source)
    at java.util.zip.ZipOutputStream.close(Unknown Source)
    at com.sun.deploy.net.HttpDownloadHelper.download(Unknown Source)
    at com.sun.deploy.cache.Cache$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.deploy.cache.Cache.downloadResourceToCache(Unknown Source)
    at com.sun.deploy.cache.DeployFileOutputStream.close(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.close(Unknown Source)
    at java.io.BufferedInputStream.close(Unknown Source)
    at sun.plugin.PluginURLJarFileCallBack.downloadJAR(Unknown Source)
    at sun.plugin.PluginURLJarFileCallBack.access$000(Unknown Source)
    at sun.plugin.PluginURLJarFileCallBack$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin.PluginURLJarFileCallBack.retrieve(Unknown Source)
    at sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source)
    at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
    Do i need to add something more .
    I am only allowed to use the below:as its the corporate policy for now.
    Java Plug-in 1.6.0_05
    Using JRE version 1.6.0_05 Java HotSpot(TM) Client VM
    Can someone please help me how to get the pack200 work in the Object tag ?
    Please advise.
    Thanks,

    InputStream in = sc.getResourceAsStream("application.jar.pack.gz");
            OutputStream out = response.getOutputStream();
            if (in != null) {
                try {
                    sendOut(in,out);
                } catch (IOException ioe) {
                    if (ioe.getMessage().compareTo("Broken pipe") == 0) {
                        sc.log("Broken Pipe while writing");
                        return;
                    } else  throw ioe;
            } else response.sendError(response.SC_NOT_FOUND);
    private void sendOut(InputStream in, OutputStream ostream)
                     throws IOException {
            byte buf[] = new byte[8192];
    System.out.println("send jar file");
            int n = in.read(buf);
            while (n > 0 ) {System.out.println(n);
                ostream.write(buf,0,n);
                n = in.read(buf);
            ostream.close();
            in.close();
        }the servlet code is above
    u should conifgure the servlet in the web.xml for urlmapping *.jar
    <servlet-mapping>
          <servlet-name>jarService</servlet-name>
          <url-pattern>*.jar</url-pattern>
        </servlet-mapping>where jarService is the name of the pack200 sevice servlet ContentType.java
    Edited by: kartheepanmirra on Jun 17, 2009 12:17 AM
    Edited by: kartheepanmirra on Jun 17, 2009 3:06 AM

  • Can java.security packages work with applets? Help required urgently.

    I recently developed an applet using java.security.KeyPairGenerator, from which I called the KeyPairGenerator to generate a pair of keys for RSA.
    The code :
    KeyPairGenerator kpg = new KeyPairGenerator.getInstance("RSA");
    However my applet refused to work and couldn't find the algorithm specified. When I replaced it with DSA, it could work. Why is this happening?

    I think your browser is using older or its own Java Virtual Machine to run the applet.
    For example IE, it has its own Microsoft Virtual Machine and if you choose to use it, it will definately fail. You can try use the JRE 1.4 Release Candidate version. Because the security is bundle with it, not sure with JRE version 1.3
    Or alternatively, you can use the appletviewer to execute the applet. Again, make sure you run the correct version of appletviewer.
    Good Luck.

  • JButtons in JApplet Don't Work (Worked with JFrame)

    This is my first time working with applets. I got basic 'HelloWorld' applets to work and now I am trying to convert a basic Pig Latin translator from a JFrame to a JApplet. The translator works perfectly as a JFrame. I followed this site to change the JFrame to a JAppet:
    JFrameToJApplet
    I just finally got the applet to successfully load on the browser, but the buttons seem to have no actions associated with them. I'm sure it's something stupid and it''s probably because I don't understand the underlying principles of applets. Understanding applets is on my list of things to do though, but for now, I would just like it to work so that I can teach my students the very basics of applets (I am an AP CS teacher).
    Here's the code (most was generated by NetBeans):
    public class PigLatinGUI extends javax.swing.JApplet {
        /** Creates new form PigLatinGUI */
        public PigLatinGUI() {
            init();
            jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            jScrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            jTextArea1.setLineWrap(true);
            jTextArea1.setWrapStyleWord(true);
            jTextArea2.setLineWrap(true);
            jTextArea2.setWrapStyleWord(true);
        /** This method is called from within the constructor 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">                         
        public void init() {
            jButton1 = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            jScrollPane2 = new javax.swing.JScrollPane();
            jTextArea2 = new javax.swing.JTextArea();
            jButton2 = new javax.swing.JButton();
            //setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            //setTitle("English to PigLatin Translator");
            //setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
            //setResizable(false);
            jButton1.setText("translate to Pig Latin");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
            jLabel1.setText("In English:");
            jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
            jLabel2.setText("In Pig Latin:");
            jTextArea1.setColumns(20);
            jTextArea1.setRows(5);
            jScrollPane1.setViewportView(jTextArea1);
            jTextArea2.setColumns(20);
            jTextArea2.setEditable(false);
            jTextArea2.setRows(5);
            jScrollPane2.setViewportView(jTextArea2);
            jButton2.setText("clear");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
            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()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel1)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jButton1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton2))
                        .addComponent(jLabel2)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
                        .addComponent(jScrollPane2))
                    .addContainerGap(18, Short.MAX_VALUE))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGap(15, 15, 15)
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton1)
                        .addComponent(jButton2))
                    .addGap(18, 18, 18)
                    .addComponent(jLabel2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(63, 63, 63))
           // pack();
        }// </editor-fold>                       
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            PigLatin p = new PigLatin();
            jTextArea2.setText(p.translate(jTextArea1.getText()));
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            jTextArea1.setText("");
            jTextArea2.setText("");
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new PigLatinGUI().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane2;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JTextArea jTextArea2;
        // End of variables declaration                  
    }

    bigbamboo wrote:
    ..In any event, I am not using init() twice as PigLatin.java is just the model and contains nothing related to the view.You were saying?
    andrew@pc1:/media$ javac PigLatinGUI.java
    andrew@pc1:/media$ appletviewer PigLatinGUI.java
    init() method count is 1
    init() method count is 2
    andrew@pc1:/media$
    Code
    // <applet code='PigLatinGUI' width=200 height='200'></applet>
    import javax.swing.ScrollPaneConstants;
    public class PigLatinGUI extends javax.swing.JApplet {
         public int initCount = 0;
        /** Creates new form PigLatinGUI */
        public PigLatinGUI() {
            init();
            jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
            jScrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            jTextArea1.setLineWrap(true);
            jTextArea1.setWrapStyleWord(true);
            jTextArea2.setLineWrap(true);
            jTextArea2.setWrapStyleWord(true);
        /** This method is called from within the constructor 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">                         
        public void init() {
    System.out.println("init() method count is " + ++initCount);
            jButton1 = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            jScrollPane2 = new javax.swing.JScrollPane();
            jTextArea2 = new javax.swing.JTextArea();
            jButton2 = new javax.swing.JButton();
            //setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            //setTitle("English to PigLatin Translator");
            //setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
            //setResizable(false);
            jButton1.setText("translate to Pig Latin");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
            jLabel1.setText("In English:");
            jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
            jLabel2.setText("In Pig Latin:");
            jTextArea1.setColumns(20);
            jTextArea1.setRows(5);
            jScrollPane1.setViewportView(jTextArea1);
            jTextArea2.setColumns(20);
            jTextArea2.setEditable(false);
            jTextArea2.setRows(5);
            jScrollPane2.setViewportView(jTextArea2);
            jButton2.setText("clear");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
            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()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel1)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jButton1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton2))
                        .addComponent(jLabel2)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
                        .addComponent(jScrollPane2))
                    .addContainerGap(18, Short.MAX_VALUE))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGap(15, 15, 15)
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton1)
                        .addComponent(jButton2))
                    .addGap(18, 18, 18)
                    .addComponent(jLabel2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(63, 63, 63))
           // pack();
        }// </editor-fold>                       
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            PigLatin p = new PigLatin();
            jTextArea2.setText(p.translate(jTextArea1.getText()));
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            jTextArea1.setText("");
            jTextArea2.setText("");
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new PigLatinGUI().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane2;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JTextArea jTextArea2;
        // End of variables declaration                  
    }I only had to add two lines to the code to confirm my original statement. This involves such basic debugging skills that I warrant you should not be coding GUIs in Java yet, let alone applets!

  • Applet does not work with a proxy server.URgent

    Hi,
    I have an asp page being hosted from a IIS server.
    The asp page has an applet which gets data from a server side component which is hosted as a service on the server side.For connection to the server I am using URLConnection object and trying to connect over a TCP connection.
    The problem occurs when I use an proxy in the middle.
    I have changed the browser settings to include the proxy.
    The following is the error I recieve:
    Full :http://172.25.11.63:4590/
    <-------------------------------->
    OPening input stream
    in Run ::::
    ERROR: Created data socket but can't open stream on
    it.172.25.11.63:4590//
    172.25.11.63:4590//
    java.io.FileNotFoundException: 172.25.11.63:4590//
         at com/ms/net/wininet/http/HttpInputStream.connect
         at com/ms/net/wininet/http/HttpInputStream.<init>
         at com/ms/net/wininet/http/HttpURLConnection.createInputStream
         at com/ms/net/wininet/WininetURLConnection.getInputStream
         at TalkClientApplet.rendezvous
         at TalkClientApplet.actionPerformed1
         at TalkClientApplet.start
         at com/ms/applet/AppletPanel.securedCall0
         at com/ms/applet/AppletPanel.securedCall
         at com/ms/applet/AppletPanel.processSentEvent
         at com/ms/applet/AppletPanel.run
         at java/lang/Thread.run
    ...Disconnecting.
    Following is my code.
    url = new URL("http://" + host +":"+i);
    urlconnection = url.openConnection();
    urlconnection.setDoOutput(true);
    urlconnection.setDoInput(true);
    System.out.println("Successfully opened the URL connection at " + "http://" + host + ":" + i );
              System.out.println ("Protocol: " + url.getProtocol());
              System.out.println ("Host :" + url.getHost());     
              System.out.println ("Port :" + url.getPort());
              System.out.println ("File :" + url.getFile() );
              System.out.println ("Full :" + url.toExternalForm());
              System.out.println ("<-------------------------------->");
    os = new BufferedWriter(new OutputStreamWriter(urlconnection.getOutputStream()));
    System.out.println("OPening input stream ");
    // is = new DataInputStream(urlconnection.getInputStream());
         System.out.println(urlconnection.getInputStream());
    is = new DataInputStream(urlconnection.getInputStream());
    The exact place where I get the error is whn i call URLConnection.openInputStream().
    Usually this error comes with a malformed URL.But the same code words without a proxy.Also I am not making any changes to my code in both scenarios that is with or without proxy.
    Please help.This is urgent and a showstopper

    Thanks for your nice solution, but unfortunatelly it does not work with lines longer than 100 chars with Netscape. It works fine with IE and appletviewer too.
    Example:
    I use this code:
    try {
                URL url = new URL(protocol,hostName,portNumber,URLstring);
                InputStream in = url.openStream();
                BufferedInputStream bis = new BufferedInputStream(in);
                StringBuffer input = new StringBuffer(60);
                int c;
                while ((c = bis.read()) != -1){
                    System.out.print((char)c);
                    input.append((char)c);
                bis.close();
                dataFromServer = input.toString();
            catch(Exception ex) {
                ex.printStackTrace();
            }I use input file test.html with exactly 100 chars ('a')
    Netscape Java Console:
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadataFromServer : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaI use input file test.html with exactly 101 chars ('a')
    Netscape Java Console:
    ?JL?yyxk?cedataFromServer : ?

  • Applets not working with Java 1.7.0_51 in MII 14.0 SP4 Patch 5

    Hi,
    I'm currently evaluating the migration of our MII 12.0 developments to MII 14.
    But I'm running in several issues just trying to use simple things like a SQL query template with an iGrid Display template in test mode.
    Used versions are: MII 14.0 SP4 Patch 5 and on client side the latest Mozilla Firefox with Java 1.7.0_51
    At first I always get a java security warning when the applet is being loaded about unsigned applications.
    At second the applet itself is not running. It always shows "No data available" and the java console shows the following errors (iResult is the id of the applet):
    iResult [ERROR] - Couldn't set query template: No Query Defined
    iResult [ERROR] - Couldn't set display template: null
    iResult [ERROR] - Couldn't set display template: null
    Is this perhaps a general problem, that the MII applets are not working with Java 1.7.x versions?
    If I call the same MII page from a client with Java 1.6.x it is working without errors.
    Do you have some suggestions for me?
    Regards Timo

    please clear your JAVA Cache. that should solve the JRE issue. thanks

  • Midi synthesizer applet working with appletviewer , but no in IE browser

    Hi ,
    The following code works OK using appletviewer , but not working with IE browser . The user can play notes from C to G , using the corresponding keyboard keys (only when typing small A,B,C,D,E,F or G , a corresponding midi note would be produced) .
    When running it using appletviewer , the notes are being heard ;
    this isn't the case when running the applet using IE browser (after removing the security warning (of showing active content) - here , the applet simply doesn't respond to the key events .
    The code is :
    import java.awt.event.*;
    import javax.swing.*;
    import javax.sound.midi.*;
    public class RandomNotes extends JApplet implements KeyListener
         private MidiChannel midiChannel;
         private int note ;
         private long timeWhilePress;
         private long timeAfterPress;
         private int firstTime = 0;
         public void start()
              try
                   Synthesizer synthesizer = MidiSystem.getSynthesizer();
                      synthesizer.open();
                  midiChannel = synthesizer.getChannels()[0];
              catch(Exception ex)
                   ex.printStackTrace();
              addKeyListener(this);
         public void keyPressed(KeyEvent e)
              firstTime++;
              switch (e.getKeyChar())
                   case 'c':
                        note = 60;
                        break;
                   case 'd':
                        note = 62;
                        break;
                   case 'e':
                        note = 64;
                        break;
                   case 'f':
                        note = 65;
                        break;
                   case 'g':
                        note = 67;
                        break;
                   case 'a':
                        note = 69;
                        break;
                   case 'b':
                        note = 71;
                        break;
                   default:
                        note = -1;
                        break;
              timeWhilePress = System.currentTimeMillis();
              if (firstTime == 1)
                   midiChannel.noteOn(note, 127);
         public void keyReleased(KeyEvent e)
              timeAfterPress = System.currentTimeMillis();
             try
                   Thread.currentThread().sleep(timeAfterPress - timeWhilePress);
              catch (InterruptedException exception)
                   exception.printStackTrace();     
            midiChannel.noteOff(note);
            firstTime = 0;
         public void keyTyped(KeyEvent e)
    }Why it runs OK using appletviewer and not under IE browser , and how can I correct the problem please , so under IE browser , the applet should respond to key events ?
    Thanks in advance ,
    Lior .

    The problem is related to the Midi itself , not to the keyPressed event - I've just checked it :
    If I add a JOptionPane.showMessageDialog(null,"Lior"); statement
    as the first line of the keyPressed method ,
    then also when running the applet under IE browser , when clicking on any letter character (eg. "j") , I see the "Lior" message appears on screen . So the problem is not with the keyboard event handling , but something related to the Midi itself .
    If you don't mind , I should post this question also in the Java sound forum (unless this is considered a crosspost , then I'll not do that) .
    Thanks in advance ,
    Lior .

  • Applet work with JRE 7_51 but NOT with JRE 7_45

    Hello,
    My major problem is, that my Applet signed with COMODO certificate DOES NOT WORK with JRE 7_45.
    The SAME applet works fine with JRE 7_45, if I sign this applet WITH A SELFMADE UNTRUSTED certificate.
    WHY the comodo signed applet doesn't run in JRE 7_45 ???
    If i launch the comodo signed applet with JRE 7_51 it works perfect !!!
    But in our company we got JRE 7_45 and I have to deal with JRE 7_45. That’s my problem.
    Could you please tell me a solution what I have to do that the comodo signed applet works also in JRE 7_45.
    Thank you!
    Philipp

    Thanks gimbal2.
    I agree the problem may be in the proxy or in the firewall but I don' to know how to prove it as if i call the servlet url from browser I dont have problems .
    The version im using is 6.45 but im sure the same problem occurs also with other versions of JRE6 .
    ... and the problem disappear with JRE7 ...
    trouble is my company want people to use JRE6
    any idea ?
    Gio

  • Applet works with IE8 but aborts with Firefox 3.6.3

    This link starts an Applet (a funny St.Valentine's one) that works perfect with IE8. Same link does some initial steps from Firefox 3.6.3 but aborts. Looking into Java Console it errors with ... but as I said, it works PERFECT with IE8!!!
    What's the problem with Firefox?
    Of course, Applets are activated in my Firefox:
    Tools/Add-ons/Plugins/JavaPlatform ... 6.0.200.2
    Note: Other Applets of my own work fine, as expected.

    Sorry, but I don't know why my previous post OMMITTED the linkand the error I was providing!
    The link I mentioned was:
    [http://www.chezmaya.com/applet/valentin.htm St.Valentine'Applet]
    and the error I've seen in the Java Console:
    Uncaught exception: string contains an invalid character
    BUT it works with IE8 and aborts with Firefox!

  • Applet failed to open xls file with Firefox and Office 2010 installed (o.s: Windows 7). It works with Office 2007.

    I load a signed applet in a web application.
    The applet open a xls file when I press the finalize button.
    It works correctly in Firefox, IE, Chrome and Safari. I have installed Office 2007.
    But when I test it in a new pc with Office 2010 installed, it does not work in Firefox browser (it works in IE, Chrome and Safari)
    This is the console java error:
    java.io.FileNotFoundException: my_file.xls (Access is denied)
    The plugin for Microsoft Office 2010 is installed.
    Java Plug-in is 1.6.0_27.
    Firefox version: 3.6 and latest version: 7
    O.S.: Windows 7
    I search in Bugzilla but not found anything about this.
    I test it with Firefox Beta - Aurora and the behaviour is the same.
    Is there any bug for Office 2010 in Mozilla Firefox?
    Any suggestion?

    Rectify the post:
    It works with Firefox 3.6, but it does not work with Firefox 7.
    Is there any bug in Firefox 7 with excel?

  • Applet plug-in for 1.3/1.4 not working with IE

    So here's my problem. I create an applet in 1.4 and convert the html with the converter and set up the plug in to work with IE. My applet works just fine, but no other applet loading in my browser from the outside works. So if I deselect the "Use SUN 1.4 jdk for Applets" box in the IE advanced tab, then I can see all the other applets from the outside, but mine won't work.
    How do I get both my applet (1.4 version) and other outside applets (probably 1.0 version) to work in IE?

    Your plugin may not be totally activated. To check, open Control Panel and click on Java Plugin. On the Basic Tab, "Enable Java Plug-in" should be checked. On the Browser tab, "Microsoft Internet Explorer" should be checked.
    To save changes, click the Apply Button at the bottom, then close the Plug-in with the "X" at the upper right.
    Both of these must be checked, otherwise some applets will not run.

  • Applet dosen't seem to work with IE

    I designed a game on my webpage on a geocities site. I used Forte as my IDE, I written it with applet, I set up everything properly and when i run the applet from Forte it worked perfectly. When i go to my website it would have the main menus and all the buttons loaded properly. BUT when i press the buttons on the website NOTHING happens. It seem like all the actionlistener doesn't work anymore. This only happens with Internet Explorer but Netscape seems to work perfectly. I really want it to run on IE because all my friends have IE. Is this because IE doesnt fully suport java/applets or is there a way i can fix that or download something so it works.
    Please help.
    Thanks.

    CP (and thats crosspost, not classpath if any1 wondered :)
    http://forum.java.sun.com/thread.jsp?forum=31&thread=341937&tstart=0&trange=15

  • I want to install an old airport express, the ones which are directly plugged into the socket - but it does not work with Maverick or Snow Leopard - can I configure it with a windows pc?

    I want to install an old airport express, the ones which are directly plugged into the socket - but it does not work with Maverick or Snow Leopard - can I configure it with a windows pc?

    The Mac running Snow Leopard should be able to configure virtually any version of the AirPort Express.
    Tell us what steps that you are taking to configure the Express and what happens after each step.

  • How to create signed applet and make it work with browser

    i hav an applet that needs to write a file to onto local system resource. i came to know that the applet needs to be signed. so i searched some guides to create a signed applet but most of them specify how to use it with applet viewer and not on a browser. plz help me with how to sign an applet and and allow it to write a file from within a browser.

    On linux, something like this:
    keytool -genkey -alias signSocket -keystore socketstore -keypass abc123 -dname "cn=your name" -storepass abc123
    jar cvf Socket.jar *.class
    jarsigner -keystore socketstore -storepass abc123 -keypass abc123 -signedjar SSocket.jar Socket.jar signSocket
    And in html:
    CODE = "YourClass.class"
    ARCHIVE = "SSocket.jar"
    ...

  • Applet does not work with JVM 1.4.1

    Hello all,
    I have a doubt with applets in JVM 1.4.1. I have a html page with has a APPLET tag, which cab file is located local in my computer. This applet connects to a server and establish a TCP/IP connection.
    I read that the security in Java Plug-in 1.4.1 was changed a lot, and now we need a policy file to grant this access. Is that right? If so, how I can change the policy file to grant this kind of access (load java applet from local disk)?
    Thanks a lot,
    Cristiana

    I have a doubt with applets in JVM 1.4.1. I have a
    html page with has a APPLET tag, which cab file is
    located local in my computer.I hope you mean a jar file. SUN's Java implementation does not understand cab files.

  • Working with frames and applets

    Hi, I am writing an applet that recieves information from a sever. before the applet loads I display a frame that allows the user to select the information that is transfered across the net.
    I block the applet from finishing until the okay button is clicked on the frame. However if I don't add my frame to the applet I can't manipulate the frame, and the frame doesn't recognize any mouse events
    When i do add the frame to the applet, the checkboxes work and the button toggles, but the click doesn't do anything.
    Finally the program works while using the applet viewer but it doesn't work across the net. Any information any one has would be greatly appreciated.

    here is the code of the frame that doesn't work
    import java.awt.*;
    import java.awt.event.*;
    public class channelSelect extends Frame implements ActionListener
    {/*This class alows the user to pick from a number of channels to be transfered
    across an internet connection*/
    private int channels = 8; //the total number of channels
    private Checkbox[] checkbox = new Checkbox[channels]; //an array of checkboxes
    private Button button1 = new Button(); //the button to signify the user has choosen the channels
    private int[] c = new int[channels]; //an array to determine which checkboxes were checked
    private boolean done = false; //a flag to tell the base class if the user is finished
    public channelSelect()
    try
    jbInit();
    catch(Exception e)
    e.printStackTrace();
    public int[] obtainChannels()
    {//returns the array of choosen channels
    return c;
    public int isDone()
    {//returns if the user is finsihed
    if(done)
    return 1;
    else
    return 0;
    private void jbInit() throws Exception
    {//sets the layout for the frame
    this.setLayout(null);
    this.setTitle("Select Channels");
    for(int j = 0; j < channels; j++)
    checkbox[j] = new Checkbox();
    checkbox[0].setBackground(new java.awt.Color(0, 200, 250));
    checkbox[0].setBounds(new Rectangle(64, 55, 198, 20));
    checkbox[0].setLabel("sinwave");
    checkbox[1].setBackground(new java.awt.Color(0, 200, 250));
    checkbox[1].setBounds(new Rectangle(64, 133, 198, 20));
    checkbox[1].setLabel("squarewave");
    checkbox[2].setBackground(new java.awt.Color(0, 200, 250));
    checkbox[2].setBounds(new Rectangle(64, 211, 142, 30));
    checkbox[2].setLabel("coolant temp");
    checkbox[3].setBackground(new java.awt.Color(0, 200, 250));
    checkbox[3].setBounds(new Rectangle(64, 289, 198, 20));
    checkbox[3].setLabel("No signal1");
    checkbox[4].setBackground(new java.awt.Color(0, 200, 250));
    checkbox[4].setBounds(new Rectangle(356, 55, 198, 20));
    checkbox[4].setLabel("No signal2");
    checkbox[5].setBackground(new java.awt.Color(0, 200, 250));
    checkbox[5].setBounds(new Rectangle(356, 133, 198, 20));
    checkbox[5].setLabel("No signal3");
    checkbox[6].setBackground(new java.awt.Color(0, 200, 250));
    checkbox[6].setBounds(new Rectangle(356, 211, 198, 20));
    checkbox[6].setLabel("No signal4");
    checkbox[7].setBackground(new java.awt.Color(0, 200, 250));
    checkbox[7].setBounds(new Rectangle(356, 289, 198, 20));
    checkbox[7].setLabel("No signal5");
    this.setBackground(new java.awt.Color(0, 200, 250));
    button1.setBounds(new Rectangle(235, 477, 98, 30));
    button1.setLabel("OK");
    button1.addActionListener(this);//new java.awt.event.ActionListener()
    public void actionPerformed(ActionEvent e)
    button1_actionPerformed(e);
    */ this.add(checkbox[0], null);
    this.add(checkbox[5], null);
    this.add(checkbox[6], null);
    this.add(checkbox[1], null);
    this.add(checkbox[7], null);
    this.add(checkbox[2], null);
    this.add(checkbox[3], null);
    this.add(checkbox[4], null);
    this.add(button1, null);
    this.setSize(610,527);
    this.setVisible(true);
    this.toFront();
    public void actionPerformed(ActionEvent e)
    {//populates the array of choosen channels
    Object source = e.getSource();
    if(source == button1)
    for(int i = 0; i < channels; i++)
    if(checkbox.getState())
    c[i] = 1;
    else
    c[i] = 0;
    done = true;
    and this is where i instantiate it and call some of it's methods.
    /* Setup channel selections */
    channel_select = new channelSelect();
    while(channel_select.isDone() == 0)
    { //wait for the channel selection to occur
    channels = channel_select.obtainChannels();
    channel_select.dispose();
    channel_select = null;
    setChannels();

Maybe you are looking for

  • How to link vbak and vbrp tables

    hi friends, i want to display lips table values based on lips-vbeln = it_vbrp-vgbel here i want a filed thru which i can link vbrp-<fieldname> to vbak/vbap-vbeln so that i can get values into it_vbrp. here is equation.   it_vbrp =>   vbak-vbeln = vbr

  • How to create/read/write textfiles in a jar archive?

    Hi! I would like to know how to create, read and write text file in a jar file? //Marcus

  • Create New Message number in Validation

    Hi, I have to create a new step in the validation, for which i want new message. please advice how to create new Message number? transaction code for it? thank you in advance, Vidya

  • Poor import sound quality

    My import settings are now set to AAC Encoder 128 kbps. Every Cd I import has popping, hissing and other noise issues on at least a couple of the tracks. What settings should I use to minimize this issue?

  • VBA with SAPbobsCOM.Recordset

    Hi all, I'm trying to do a report using VBA microsoft word. I manage to connect to the database using the DI API. But when i tried to do the SAPbobsCOM.Recordset, i got error. Need advice. Regards, Bruce.