3 Replies Latest reply on Aug 13, 2010 4:34 AM by darrylburke

    deployment of applet

      I have code that runs within the development environment with no problem but when i try to deploy it i get errors.

      this is the code

      package request;

      import java.awt.*;
      import java.util.*;
      import javax.mail.*;
      import javax.mail.internet.*;
      import java.util.logging.Level;
      import java.util.logging.Logger;

      public class request extends java.applet.Applet{

           Button sendrequest,clear;
           TextField tex1,tex2,tex3,tex4,tex5;

           public void init(){
                setLayout(new GridLayout(6,2,2,5));
                add(new Label("Customer Name"));
                tex1=new TextField(22);
                tex2=new TextField(22);
                add(new Label("Account Number"));
                tex3=new TextField(22);
                add(new Label("Viewing Card Number"));
                tex4=new TextField(22);
                add(new Label("Request Type"));
                tex5=new TextField(22);
                add(new Label("Request Reason"));
                sendrequest = new Button("Send Request");
                clear=new Button("Clear");

           public boolean action(Event evt,Object arg){
                if(evt.target instanceof Button){
      try {
      makechoice((Button) evt.target);
      } catch (Exception ex) {
      Logger.getLogger(request.class.getName()).log(Level.SEVERE, null, ex);

                     return true;
                } else return false;

           void makechoice(Button b) throws Exception{
                if (b==sendrequest){
                     String mess=null;
                     Date date;
                     date=new Date();
                     mess=date.toString() + "\r\n";
                     mess=mess + "Customer Name: "+ tex1.getText() + "\r\n";
                     mess=mess + "Account Number: "+ tex2.getText() + "\r\n";
                     mess=mess + "Card Number: "+ tex3.getText() + "\r\n";
                     mess=mess + "Request Type: "+ tex4.getText() + "\r\n";
                     mess=mess + "Request Reason: "+ tex5.getText() + "\r\n";

      }else {

      void postmail(String mess) throws MessagingException
      boolean debug = false;
      String recipient="YOUR EMAIL ADDRESS HERE";
      String subject="change request";
      String from="YOUR EMAIL ADDRESS HERE";
      //Set the host smtp address
      Properties props = new Properties();
      props.put("mail.smtp.host", "YOUR SMTP SERVER ADDRESS HERE");

      // create some properties and get the default Session
      Session session = Session.getDefaultInstance(props, null);

      // create a message
      Message msg = new MimeMessage(session);

      // set the from and to address
      InternetAddress addressFrom = new InternetAddress(from);

      InternetAddress addressTo = new InternetAddress(recipient);

      msg.setRecipient(Message.RecipientType.TO, addressTo);

      // Setting the Subject and Content Type
      msg.setContent(mess, "text/plain");


      This is the html produced from the designe environment java beans

      <TITLE>Applet HTML Page</TITLE>

      *** GENERATED applet HTML launcher - DO NOT EDIT IN 'BUILD' FOLDER ***

      If you need to modify this HTML launcher file (e.g., to add applet parameters),
      copy it to where your applet class is found in the SRC folder. If you do this,
      the IDE will use it when you run or debug the applet.

      Tip: To exclude an HTML launcher from the JAR file, use exclusion filters in
      the Packaging page in the Project Properties dialog.

      For more information see the online help.

      <H3><HR WIDTH="100%">Applet HTML Page<HR WIDTH="100%"></H3>

      <APPLET codebase="classes" code="Requestor/Requestor.class" width=350 height=200></APPLET>

      <HR WIDTH="100%"><FONT SIZE=-1><I>Generated by NetBeans IDE</I></FONT>

      and this is the errors i recieve from the java cnsole

      java.lang.NoClassDefFoundError: javax/mail/Message
           at java.lang.Class.getDeclaredConstructors0(Native Method)
           at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
           at java.lang.Class.getConstructor0(Unknown Source)
           at java.lang.Class.newInstance0(Unknown Source)
           at java.lang.Class.newInstance(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.ClassNotFoundException: javax.mail.Message
           at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
           at java.lang.ClassLoader.loadClass(Unknown Source)
           at java.lang.ClassLoader.loadClass(Unknown Source)
           at java.lang.ClassLoader.loadClassInternal(Unknown Source)
           ... 8 more
      Caused by: java.io.FileNotFoundException: G:\java source\requestor\Requestor\build\classes\javax\mail\Message.class (The system cannot find the path specified)
           at java.io.FileInputStream.open(Native Method)
           at java.io.FileInputStream.<init>(Unknown Source)
           at java.io.FileInputStream.<init>(Unknown Source)
           at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
           at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
           at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
           at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
           at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
           at java.security.AccessController.doPrivileged(Native Method)
           ... 12 more
      Exception: java.lang.NoClassDefFoundError: javax/mail/Message

      It seems to point to the Mail.jar library but works in the designe environment. I have the relevent libraries in the class path and have referenced the library from the html as well but get the same result. I have looked at the relevent docs with regards to deployment and have recompiled the code in a number of ways with different settings with the same results. I would be very grateful if you could have a look at this and tell me where i am going wrong.

      With thanks in adavance