Start applet from main without html or appletviewer

Hello,
I have an applet that I would like to function outside of a web page or the appletviewer.
How would I open an instance of the applet in a main function of a class?
My applet class is entitled ViewData.
Thank you in advance,
Chris

import java.awt.*;
import javax.swing.*;
public class ViewData extends JApplet {
  public void init() {
    JPanel panel = new JPanel();
    panel.setBackground(Color.red);
    panel.add(new JLabel("ViewData", SwingConstants.CENTER));
    getContentPane().add(panel);
  public static void main(String[] args) {
    JFrame frame = new JFrame("ViewData Applet");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JApplet applet = new ViewData();
    frame.getContentPane().add(applet);
    frame.setSize(400, 250);
    frame.setLocation(375, 100);
    applet.init();
    applet.start();
    frame.setVisible(true);
}

Similar Messages

  • Way to guarantee start-up from main disk?

    Using OS 10.6.8 on a MacPro, I use SuperDuper to daily back-up and make a clone of my main Hard Drive to another internal Hard Drive. I also schedule my computer to automatically start up every morning. The problem is nine time out of ten the computer starts up from the main drive but occasionally it will boot from the clone. If I don't catch it, things can get messy real fast as I start altering what are essentially backed-up files.
    So, the question: is there a way to insure the computer always, without fail, boots up from the main drive?

    The only thing that could explain this behavior then is for some reason the backup is somehow coming on line before you primary drive and being found as the only available drive to boot from at the time it is needed.  I would check the drives with Disk Utility and maybe move them to a different bay just to experiment.
    By the way, instead of shutting down I recommend you just sleep your machine.  That's what I do.  Daily it wakes up to do it's backup and then goes back to sleep.  Everything is basically off anyhow when the mac pro sleeps.  No fans, no drives.  And then there is no need to boot when you need the machine.

  • Start Application from Terminal without Open

    I need to start an application from the terminal without using open - I'm using the java exec() command to keep a handle to the application process, and when I use open it returns a handle to open instead of a handle to the application. When I try to putting in the application name, it says "cannot execute binary file". The application also won't let me look inside it to find the name of the executable. Is this possible? How do I do this?

    Some applications are not "application bundles". Usually these are older Carbon based apps that may have been ported over from OS 9. <Control>-clicking on these applications will not give you the "Show Package Contents" option because they are not folders (like application bundles are).
    However, you can launch these apps from the command line using "LaunchCFMApp". You'll have to specify the full path to LaunchCFMApp followed by the path to the app you want to launch like this:
    /System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp /path/to/app/you/want/to/launch
    I'm not a java programmer but perhaps you could use a command similar to the above with java's exec().
    HTH,
    Steve
    EDIT: Oops, I just re-read your original post... I suppose even if LaunchCFMApp works with java exec() you may still get handle to LaunchCFMApp instead of the actual application.

  • Referencing a "locally installed" Java applet from a server-based HTML page

    How does one reference a "locally installed" Java applet from a server-based HTML page (i.e. via the applet, object, or embed tags)? I have seen references in documentation that this is possible, but I have not seen any examples. I have tried a few things, but nothing seems to be working.
    Some background...
    I'm working on a web site that aggregates Internet video. For many users, I would like the site to work "without" requiring Java to be installed (or any prompts, etc.). This version of the site allows users to stream videos directly over the Internet and does not require any sort of access to the local system.
    However, in addition, I have a download manager that can be installed on the local system. Currently, it's a Windows-based "service" that is always running in the background, downloading files, etc. (with plans to later support other OSes).
    My dilemma is trying to communicate between my web site running in the local browser (executing JavaScript code) and the download manager. I call this component the "gateway". I need the gateway to be able to do the following:
    1) Pass user credentials from the web browser UI to the download manager (so it can communicate with my servers).
    2) Check the status of downloaded videos
    3) Launch a local media player (such as Windows Media, QuickTime, etc.) (or perhaps tell the download manager to launch the media player).
    Under Windows XP, I have an ActiveX control that can do these things. It communicates with the download manager via reading/writing to a shared XML configuration file.
    Unfortunately, under Vista and IE7 Protected Mode, ActiveX controls have become very restricted and my gateway no longer works. As such, I am looking at using Java for the gateway (also giving me the additional benefits of supporting additional browsers and OSes).
    From my understanding, I believe I can created a "face-less" Java applet, whose methods can be called from JavaScript. Ideally, I'm thinking I could install the applet onto the local system at the same time the download manager is installed. This would give the applet the security permissions it needs to communicate with the download manager.
    Thanks for any help and suggestions!

    Hi,
    Put the .jar file and the .class file in the path mentioned in one of the aliases in the plsql.conf file like /images or create
    a seperate directory and create an alias like /applets "path" in the plsql.conf file.
    <html>
    <body>
    <applet code=com.chartapplet.chart.BarChartApplet
    codebase=/applets/
    archive=/applets/chart.jar width=300 height=200>
    <param name=background value="white">
    </body>
    </html>
    Hope this helps.
    Thanks,
    Sharmila

  • Problem Running a java applet from an HTML page

    I can run my applet at the command prompt with:
    appletviewer coffee.html
    But when I try and open the Coffee.html by opening
    the page in Internet Explorer I get the following message:
    Can't find Database driver class: java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
    Code: createcoffees.java
    import java.applet.*;
    import java.sql.*;
    public class CreateCoffees extends Applet{
         public void init() {
              Statement stmt;
              Connection con;
              try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              } catch(java.lang.ClassNotFoundException e) {
                   System.err.print("ClassNotFoundException: ");
                   System.err.println(e.getMessage());
              try {con = DriverManager.getConnection("jdbc:odbc:hq","afm", "afm");
                   stmt = con.createStatement();                                   
                          stmt.executeQuery("SELECT * FROM RM");
                   stmt.close();
                   con.close();
              } catch(SQLException ex) {
                   System.err.println("SQLException: " + ex.getMessage());
    }

    Is your jdbc-odbc driver properly loaded? Its very clear that its a class not found exception which is thrown by this:
    try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());

  • Launching Web Start Program from an Applet?

    Hi,
    I need to launch web start program from an applet.
    How can I do that?
    I have tried opening a new web page pointing to the jnlp file from an applet. But, that does not seem to start the web start.
    Thanks in advance
    rg

    I am new to this so may be my questions will appear stupid to a pro, but this is an erro I am getting at compile:
    Can't make static reference to method java.lang.Process exec(java.lang.String) in class java.lang.Runtime.
         Runtime.exec("test.exe");
    What could be the problem?
         ^

  • How to open an Applet from a text link in a HTML Page

    Hi There
    How to open an Applet from a text link
    in a HTML page
    For example I have a HyperLink "Open Applet"
    When a user clicks that link i want to open a
    Applet in a AWT Window.
    How can i do this
    Will any one help me?
    -Ramya

    u can use javascript for that
    <SCRIPT language="javascript">
    function loadAppNow() {
    document.write("<APPLET ......></APPLET>")
    </SCRIPT>
    LoadApplet
    this will overwrite the applet on current window
    There are many good ways other than document.write to open in same window. I don't remember the syntax right now.
    Plz. refer to javascript tutorial for that.
    even you can insert the applet while retaining previous contents. its quite easy actually.
    regards....bhart

  • How to pass the value from JSP or HTML  to Applet

    Plz reply ....How can we pass the value from the JSP Page or from HTML page to Applet embedded in same page....

    Hi,
    <applet codebase = "."
    archive = foo.jar"
    code = "com.bar"
    name = "bar"
    id = "bar"
    width = "<%=Request["width"] %>"
    HEIGHT = "<%=Request["appHeight"] %>"
    hspace = "0"
    vspace = "0"
    align = "middle"
    alt     = "Applet is Loading..."
    >
         <param name="LANGUAGE"                value="<%=Request["lan"] %>">          
         <param name="LOGOUT_USER_URL"           value="EndSession.asp">
         <param name="DATA_READ_INTERVAL"      value="10000">
         <param name="REFRESH_INTERVAL"           value="5000">     
         <param name="DEFAULT_FONT"           value="Arial">
    </applet>
    pass values @ ur html or jsp page to Applet as parameters.
    Refer above code. By using getParameter() method of Applet, u can take values inside applet.

  • HT4889 Hi. I`ve just started transferring from my old Imac to a new Macbook, using the WIFI. But I realize it will take days to get it done. Can I cancel the process, and start over again using the thunderbolt port? Without causing any trouble?

    Hi. I`ve just started transferring from my old Imac to a new Macbook, using the WIFI. But I realize it will take days to get it done. Can I cancel the process, and start over again using the thunderbolt port? Without causing any trouble?

    See Pondini's Setup New Mac guide for possible answers.

  • Problem loading Applets from Jar files on 64 bit machine

    I am developing an applet (extends Applet but uses swing components) using JDK 1.6 (Though these problems still happen in JDK 1.7) and I am unable to get the applet to load on a 64 bit machine in most cases. The web server(s) are running on localhost and I am connecting on the same machine using a local network ip address (such as 192.168.*.*)
    Below are all of my test results. Can someone provide a suggestion for repairing this? The Windows Server machine is a clients computer I access to it via remote desktop but I can't do much with it though I do have administrator rights. The Windows 7 machine is my development platform so I have been able to do extensive testing on it.
    This problem is presenting in the following environments when trying to load an applet from JAR files in a HTML document using the Applet or Object tag.
    Windows Server 2008 (Intel Chipset)
    Tested Browsers:
    Internet Explorer 9 (32 bit) - Shows it is blocked by default then simply shows an x when loaded from a web page, same result when loading from local drive.
    Windows 7 Home Premium (AMD Chipset)
    Tested Browsers:
    Firefox 6.0.1 (32 bit) - Java logo shows with spinner, after a few minutes there is finally an error that a class in the jar was not found
    Internet Explorer 9 (32 bit) - Java logo shows with spinner, after a few minutes there is finally an error that a class in the jar was not found
    Internet Explorer 9 (64 bit) - Java logo shows with spinner and most of the windows desktop manager freezes, keyboard is the only thing that responds so you can alt-tab to another app to regain control of the desktop.
    Chrome (32 bit) - Java logo shows with spinner, after a few minutes there is finally an error that a class in the jar was not found
    The only way I have been able to get a Java applet to run on a 64 bit machine are the following ways.
    Firefox 9 nightly (64 bit) works perfectly! Go Firefox!
    Internet Explorer 9 (32 bit) loading directly from drive (c:\...)
    Chrome (32 bit) loading directly from drive (c:\...)
    Firefox 6.0.1 (32 bit) loading directly from drive (c:\....)
    Can someone please help! I've been fighting with this bug for over a week and I can't find anything that will solve it, I have noticed that in some cases if my jar has very little code in it than it will run on the server, but the minute I start adding things to it the jar won't load anymore.

    jschell wrote:
    rritoch wrote:
    I am developing an applet (extends Applet but uses swing components) using JDK 1.6 (Though these problems still happen in JDK 1.7) and I am unable to get the applet to load on a 64 bit machine in most cases.
    To clarify...
    1. You have tried it on 32 bit machine? Exactly which OS?I tested this on Windows Vista Business which is in 32 bit mode and the applets run without any problems
    >
    2. Your only 64 bit tests have involved 2008/Win7?
    If so then I would suspect something with windows not java. Probably permissions.
    The web server(s) are running on localhost and I am connecting on the same machine using a local network ip address (such as 192.168.*.*)
    Yes, I haven't tried running the jars on other operating systems.
    >
    I don't understand that. If you are running on localhost then you should connect to localhost. If running on an IP then you should connect to that. Perhaps you meant that you have tested using both of those?I'm testing using the lan ip address but I'm connecting from the same machine. I've tried localhost and that didn't work so I tried lan ip since that will likely have a different java security context than localhost. At first I was blaming the IIS server but I downloaded the jar directly and using HTTP fox was able to verify that the jar is being sent with the correct mime-type and that the server can upload the jar file without a problem. This leaves me to believe the problem is with Java.

  • ClassFormatError when attempting to load an applet from within a JSP

    Greetings everyone.
    I have a problem that i seem unable to solve.
    I've created a web application. I'm using Java 1.4.2_05 and Tomcat. Right now i'm trying to load an applet from a JSP and i'm getting an error that, try as i might, i can't understand why it happens.
    Here is some detailed info:
    The applet's code:
    package smpb.myapp.controllers;
    import java.applet.Applet;
    import java.awt.Graphics;
    public class GUIApplet extends Applet
         public void init()
         public void stop()
         public void paint(Graphics g)
                  g.drawString("Hey hey hey",20,20);
               g.drawString("Hellooo World",20,40);
    The JSP's code:
    <%@ page language="java"
                   import="java.util.*"
                   session="true" %>
    <%
         String name = (String) request.getSession().getAttribute("userName");
    %>
    <html>
         <head>
              <title>Login</title>
         </head>
         <body>
              <h1><p align="center">Application</p></h1>
              <br>
              Welcome <%= name %>! Thank you for logging in!
              <br><br><br>
              <applet align="middle" code="smpb.myapp.controllers.GUIApplet.class" codebase="./" archive="MyApp_applets.jar">
                   Your browser does not support this feature.
              </applet>
              <br><br>
              <a href='<%=request.getContextPath() + "/LogOut"%>'>Log Out</a><br>
         </body>
    </html>-------------------------------------------
    When i reach this JSP the applet fails to load and i get the following error message at the java console:
    Loading applet ...
    Initializing applet ...
    Starting applet ...
    Connecting http://127.0.0.1/MyApp/MyApp_applets.jar with no proxy
    Connecting http://127.0.0.1/MyApp/MyApp_applets.jar with cookie "JSESSIONID=A8EECE5E39458739C760D8907762C507"
    Last modified time and/or expiration value is not available.  Jar file will not be cached.
    Connecting http://127.0.0.1/MyApp/MyApp_applets.jar with no proxy
    Connecting http://127.0.0.1/MyApp/MyApp_applets.jar with cookie "JSESSIONID=A8EECE5E39458739C760D8907762C507"
    Connecting http://127.0.0.1/MyApp/smpb/myapp/controllers/GUIApplet.class with no proxy
    Connecting http://127.0.0.1/MyApp/smpb/myapp/controllers/GUIApplet.class with cookie "JSESSIONID=A8EECE5E39458739C760D8907762C507"
    Last modified time and/or expiration value is not available.  Jar file will not be cached.
    Connecting http://127.0.0.1/MyApp/smpb/myapp/controllers/GUIApplet.class with no proxy
    Connecting http://127.0.0.1/MyApp/smpb/myapp/controllers/GUIApplet.class with cookie "JSESSIONID=A8EECE5E39458739C760D8907762C507"
    java.lang.ClassFormatError: smpb/myapp/controllers/GUIApplet (Bad magic number)
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
         at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:157)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
         at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:123)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
         at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:561)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
         at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1856)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
         at sun.applet.AppletPanel.run(AppletPanel.java:298)
         at java.lang.Thread.run(Thread.java:534)
    Exception: java.lang.ClassFormatError: smpb/myapp/controllers/GUIApplet (Bad magic number)-------------------------------------------
    The JSP is in the root directory of the web application's path right along with the jar file. The jar file itself has the following structure:
    Archive:  HelpDesk_applets.jar
      Length     Date   Time    Name
            0  05-17-06 12:17   META-INF/
          106  05-17-06 12:17   META-INF/MANIFEST.MF
            0  05-10-06 17:14   smpb/
            0  05-10-06 17:14   smpb/myapp/
            0  05-12-06 16:50   smpb/myapp/controllers/
          794  05-12-06 17:15   smpb/myapp/controllers/GUIApplet.class
          900                   6 filesNow, i've tried loading the very same jar file that i use in the JSP through a static HTML which is virtually identical to the JSP i presented and everything works just fine. I've checked and rechecked to see if all the permissions to access the jar file were accurate, i checked to see if Tomcat had it's MIME settings correctly configured so that there was no chance that the files were being corrupted during the load (as that is a usual cause for the problem, or so i've gathered) but to no avail. I've searched the web, including these forums, and found similar problems but no conclusive solution. I can't seem to figure out, at all, what could possibly be wrong. Does anyone have any ideas? I've tried to be as thorough as i could from the start, so, any help would be deeply appreciated.

    Hi mshah101,
    This can happen if the applet is compiled using an higher version of java and the browser is pointing to an older version (even if minor version number is higher)

  • Creating an Applet from an Application

    So i'm developing my own version of the '80s Space Invader game for class, and one of the requirments is that we have to turn in an application, but also post an Applet version on a website. The game is pretty much done, but I am having trouble creating the Applet from the Application. I've done most of the stuff that i thought you were supposed to do. The thing is, it will run whenever i use the appletviewer from the dos prompt just like it does when i'm running the application. However, when Ii try to view it in an actuall explorer window, it wont load.
    The way the program was designed, it had a "SpaceInvaders" class that had the main method, which only had about 4 lines. Then i had a DrawFrame class that extended JFrame, and that had the bulk of the code in it. The main method of the SpaceInvaders class had a "DrawFrame frame = new DrawFrame();" statement, and then a couple set.whatever statements. to change it to an applet, i just commented out the whole of the SpaceInvaders class, then i renamed the DrawFrame class to "public class SpaceInvaders extends JApplet" changed the consructor to the "init()" method, and commented out the setSize and setTitle statements, and also i imported java.applet.*;
    when i try to run the html file in firefox, all i get is the frame with a little red 'X' in it, and at the bottom it says "Applet SpaceInvaders notinited"
    any help, ideas, or tips would be greately appreciated. Thanks in advance, and if you need any more info, let me know.

    i created a very simple applet:
    import java.applet.*;
    import java.awt.*;
    * The HelloWorld class implements an applet that
    * simply displays "Hello World!".
    public class HelloWorld extends Applet {
        public void paint(Graphics g) {
            // Display "Hello World!"
            g.drawString("Hello world!", 50, 25);
    }and it ran just fine inside of a browser. I've also ran other applets that should be very similar to mine, but still mine doesn't work.

  • Loading (and hiding) an applet from forms 6i (deployed on iAS 1.0.2)

    Hi:
    We have an existing in-house Forms 6i application deployed on Oracle iAS 1.0.2 (client PC is running Win XP).
    I need to do the following after user completes a specific action on the form (e.g. click a button):
    - loading an applet to downloading a file from the server to client machine
    - the applet (and the associated HTML page, if any) must be hidden from the user
    - after the downloading process is completed, the applet (and associated HTML page) is terminated without any impact on the Oracle Form
    Any help (and examples if available) is much appreciated
    Thks

    Hello,
    Applets accept parameters, so you could use these parameters to move or resize the main frame (like the Forms applet does).
    If your are the owner of the Applet, you also could envisage to transcript it into a Java Bean, then it would be totally transparent for the user.
    Francois

  • Problem loading applet from tomcat

    I am facing a problem loading the batik applet from tomcat. I have placed all the jar files of batik in ROOT directory in tomcat. Along with the folder containing the batik applet. Still i receive the following exception when trying to load the html page containing batik applet.
    Applet tag in html page is:
    <applet codebase = "." code="batik_applet.BatikApplet.class" name="myApplet" width="1600" height="1200" hspace="0" vspace="0" align="middle" archive="batik-swing.jar,batik-gvt.jar,batik-bridge.jar,xml-apis-ext.jar,batik-css.jar,batik-util.jar,batik-dom.jar,batik-svg-dom.jar,batik-anim.jar,batik-awt-util.jar,batik-codec.jar,batik-ext.jar,batik-extension.jar,batik-gui-util.jar,batik-parser.jar,batik-script.jar,batik-svggen.jar,batik-transcoder.jar,batik-xml.jar,js.jar,pdf-transcoder.jar,xalan-2.6.0.jar,xerces_2_5_0.jar,xml-apis.jar">
    </applet>
    I already have a folder named batik_applet containing BatikApplet.class in the ROOT directory.
    ========Exception===========
    network: Connecting http://localhost:8080/servlet/batik_applet/BatikApplet.class with proxy=DIRECT
    network: Connecting http://localhost:8080/servlet/batik_applet/BatikApplet.class with cookie "JSESSIONID=1A75299B77372108560B4DF8DC65A3A6"
    network: Connecting http://localhost:8080/servlet/batik_applet/BatikApplet/class.class with proxy=DIRECT
    network: Connecting http://localhost:8080/servlet/batik_applet/BatikApplet/class.class with cookie "JSESSIONID=1A75299B77372108560B4DF8DC65A3A6"
    load: class batik_applet.BatikApplet.class not found.
    java.lang.ClassNotFoundException: batik_applet.BatikApplet.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    basic: Exception: java.lang.ClassNotFoundException: batik_applet.BatikApplet.class
    Any help would be appreciated.

    Assuming that your applet is not in a jar file (don't see a value for archive)
    you have a file callsed ProcessStatus.class in a folder WEB-INF\classes relative to
    the location of the jsp file.
    So if the jsp file is in
    myJSPFileFolder
    the class should be in:
    myJSPFileFolder\WEB-INF\classes
    If you want to see when the jre is trying to load and where it it trying to load it from you
    can inspect a full trace, to turn the full trace on (windows) you can start the java console, to be found here:
    C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
    In the advanced tab you can fill in something for runtime parameters fill in this:
    -Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
    if you cannot start the java console check here:
    C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    add or change the following line:
    javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    for 1.5:
    deployment.javapi.jre.1.5.0.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    The trace is here:
    C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    The trace should show something like :
    Caused by: java.io.FileNotFoundException: http://server/location/filename.class (The system cannot find the path specified)

  • Start:applet not initilaized error

    Hi friends,
    I'm getting Start:applet not initilaized error when i'm running a program...
    saved a notepad file as Testloan.java used javac Testloan.java and appletviewer Testloan.java to execute the applet here is my code...
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    <html>
    <applet code="Testloan.class" width=300 height=100>
    </applet>
    </html>
    public class Testloan extends Applet implements ActionListener
    TextField t1,t2,t3;
    Label lp,lr,lmp;
    Button b1,b2;
         public void init()
         lp=new Label("Principal");
         lr=new Label("Rate");
         lmp=new Label("Payment");
         add(lp);
         add(lr);
         add(lmp);
         t1=new TextField();
         add(t1);
         t2=new TextField();
         add(t2);
         t3=new TextField();
         add(t3);
         b1=new Button("submit");
         add(b1);
         b1=new Button("Exit");
         add(b2);
         b1.addActionListener(this);
    b2.addActionListener(this);
    public void start() {
    //win.setVisible(true);
    public void stop() {
    //win.setVisible(false);
    public static int months(int principal,double rate,int payment)
              Testloan tl=new Testloan();
              principal=Integer.parseInt(tl.t1.getText());
              rate=Double.parseDouble(tl.t2.getText());
              payment=Integer.parseInt(tl.t3.getText());
              int p=principal;
              double eRate = rate / 1200.0;
              int month =0,np=1;
                   while(np>0)
                   month = month + 1;
                   np= (int) (p*(1+eRate)-payment );
                   System.out.println(np+"/n");
                   p = np;
              return month;
    public void actionPerformed(ActionEvent e)
    String cmd = e.getActionCommand();
    }

    First, the code you posted was mangled by the forum formatting software. When you post code, select it and click the CODE button above the typing area, which will prevent that, and maintain your formatting.
    When you ran the appletviewer program from the cmd window, error information was posted to it by the java command. Did you look at it? It says that you have a NullPointerException at this line
    add(b2);because there's a typo in this line
    b1 = new Button("Exit");which should have assigned a value to b2, not b1
    Read and understand the error messages that java creates, they almost always point exactly at the problem and allow you to debug the cause.

Maybe you are looking for

  • 3600 Series Access Point Problem

    Have a AIR-CT5508-K9 Controller running 7.0.116.0 software. Just purchased 3 AIR-CAP3602I-A-K9 access points. When these try to join the controller we receive the following error message. %CAPWAP-3-UNSUPPORTED_WLC_VERSION: Unsupported version 7.0.116

  • Aggregation level ZFI_FINGL is locked by the Change and Transport Organizer

    Dear, After transport from a dev to prod system I get this message on the planning modeler : "System is not set to changeable - objects are not changeable Aggregation level ZFI_FINGL is locked by the Change and Transport Organizer" Do you know how to

  • Accessing label in another class?

    I'm trying to learn Java so sorry for the very simple question but I'm trying to change the text of a label in another class. I think I need to create a new instance of this label to access it from the second class but I just can't seem to get it to

  • Moving/sorting of images

    I am a photographer who likes to arrange what I have shot after I have put the images into Lightroom. I often want to drag one shot before another to make the presentation more powerful. With even most of the cheapest programs I can drag and drop ima

  • Creating select-options dynamically

    Hello Gurus, I have following program with me. CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING it_fieldcatalog = itab_display IMPORTING ep_table = d_ref. ASSIGN d_ref->* TO <F_FS>. SELECT * FROM (table) INTO CORRESPONDING FIELDS OF TA