Getting java program to run (really basic)

Hi,
I'm used to running java programs through the programs I write with, like Eclipse, but now I'm trying to run a program on a compuyer without those things and I'm stuck.
I'm running Windows XP and have downloaded the SDK Version 1.4.2, The java.com website says I have the latest software, everything is up to date.
All the sites I see say that the way to run a program is to use the 'javac' command from the command prompt. However, doing this (with or without a file name appended) gives me the error: 'javac is not recognized as an internal or external command, operatable program or batch file.'
What do I need to do to run a simple java program from a bunch of .java files?
Help much appreciated, thanks.

All which instuructions?
1. I've followed all the instructions at 'Installation Instructions', http://www.java.com/en/download/help/5000010300.xml. They have instructions to
.A: Download and Install: All done.
.B: Enable and Configure: They say it only relates to browsers and applets
.C: Test installation: Test comes out positive.
2. The files that were downloaded: Contain no instructions
3. All the 'Enable' instructions found here: http://www.java.com/en/download/help/index_configuration.xml
These relate to:
.A:Switching between Microsoft VM and JRE
.B:Enabling JRE for browsers and Applets
.C: Clearing the cache
.D: Viewing the console,
etc etc. None of them seem to be about setting a path.
Can you tell me which instructions you mean?
Thanks

Similar Messages

  • Can a java program be run in the background?

    Hi all,
    Can a java program be run in the background without the user being aware of it? I need to make a program that continuosly monitors a pc at regular intervals and runs at all time. It should be hidden(shouldn't display on the screen while running) from the user, and also, can it be run as a system file so that even if a user checks he/she would think of it as a system file?

    I'm the administrator of all the computers. Then as I said there are commercial applications that do that.
    Presumably you expect a problem now. And implementing an acceptable solution is going to take you months. Because not only need to 'hide' the application, you also need to set up all the monitoring and logging capability. And the first will require quite a bit of JNI work along with testing (in particular as it could interfer with existing applications on the users computers.)
    I need to
    install the software in all the machines and i want
    that the users who use the machine should not be able
    to close the program through the task manager. If the users have admin rights then they can terminate a windows service.
    And if they don't have admin rights then you can simply turn off the ability to install anything.
    I want
    to know what the resources of the computers are and
    that if anyone has added a resource to it or
    not(attaching a flash usb thumbdrive etc). Lots of JNI.

  • A Java program that runs automatically at a given time of day

    Okay Iam at the ending stages of a Java Assignment that is a MySql database, Hibernate for Mapping with a Java Server Faces front-end. All I need to do now is send emails at set time every week. Normally I know what to search for but frankly Iam stumped. Iam really just looking for a starting point for something that can run a Java Program at a set time of the week. PS my OS is Ubuntu if that is relevant but I was hoping for something that isn't platform specific so that it is portable.
    Cheers in advance.

    You can use the possibilities of your operating system, in this case Ubuntu.
    Just drop a shell script that runs your java program in the /etc/cron.weekly directory.
    --janeiros                                                                                                                                                                                                                                                                                                                                                                   

  • Can't get Java page to run

    I am probably in the wrong place here, and for that I apologize. We use a program at our school called Power School which is on-line. In order to enter student marks, one accesses a page which is generated by Java. Since I purchased this new computer, I have been unable to access the gradebook. For a while, I was getting an Run Time error, so I installed the Run Time Environment. Then a Big Math error appeared after I finished the installation. So I reinstalled Jave (JRE - 6 u 11) and now I am getting the error about connection shown below. No one at the school can figure it out or get the program running. Can anybody help me, out there?
    Here are the details of the error. It says "Encountered Connection Error, see your adminsitrator" I can get on-line just fine, and my administrator has no idea what the problem is and so cannot fix it. Any advice would be greatly appreciated.
    com.pearson.powerschool.sdk.common.SDKRemoteException:java.net.SocketException: Unknown proxy type : HTTP
    at com.pearson.powerschool.sdk.system.HttpInvokeInvocationHandler.invoke(HttpInvokeInvocationHandler.java:51)
    at $Proxy1.getSchools(Unknown Source)
    at com.pearson.powerschool.gradebook.Main.login(Main.java:358)
    at com.pearson.powerschool.gradebook.Main.startUI(Main.java:91)
    at com.pearson.powerschool.gradebook.Main.access$000(Main.java:36)
    at com.pearson.powerschool.gradebook.Main$1.run(Main.java:124)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at com.pearson.powerschool.gradebook.CustomEventQueue.dispatchEvent(CustomEventQueue.java:19)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Caused By:java.net.SocketException:Unknown proxy type : HTTP
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:139)
    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:124)
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1321)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
    at org.meno.remoting.httpinvoke.client.HTTPInvokeProxyFactory.invoke(HTTPInvokeProxyFactory.java:145)
    at org.meno.remoting.httpinvoke.client.HTTPInvokeProxyFactory.access$000(HTTPInvokeProxyFactory.java:23)
    at org.meno.remoting.httpinvoke.client.HTTPInvokeProxyFactory$1.invoke(HTTPInvokeProxyFactory.java:68)
    at $Proxy1.getSchools(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.pearson.powerschool.sdk.system.HttpInvokeInvocationHandler.invoke(HttpInvokeInvocationHandler.java:40)
    at $Proxy1.getSchools(Unknown Source)
    at com.pearson.powerschool.gradebook.Main.login(Main.java:358)
    at com.pearson.powerschool.gradebook.Main.startUI(Main.java:91)
    at com.pearson.powerschool.gradebook.Main.access$000(Main.java:36)
    at com.pearson.powerschool.gradebook.Main$1.run(Main.java:124)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at com.pearson.powerschool.gradebook.CustomEventQueue.dispatchEvent(CustomEventQueue.java:19)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    Looks like a configuration problem to me. Perhaps there's some place where you set up the options which tell the program how to connect to the Internet (because it looks like that's what it's trying to do). If so, browse through there until you find some settings involving "proxy" or something like that. Find somebody else who is using the program and see what they have for those settings.
    Or call the support line for the product, if there is such a thing?
    Edit: I see the product comes from [http://www.powerschool.com/]. There's a Contact Us link on that page. Actually two of them.

  • Java program not running by the Ant

    i have a small java program.
    its a classpath problem.
    cant figure out where is the problem.
    i am running the code via Ant.
    build.xml
    <?xml version="1.0"?>
    <project name="myproject" basedir="." default="all">
        <property name="src.dir"     value="src"/>
         <property name="classes.dir" value="classes"/>
         <property name="lib.dir"     value="C:/tomcat/webapps/axis/WEB-INF/lib"/>
         <property name="runclass" value="TestClient"/>
         <target name="all" depends="clean,compile"/>
         <target name="clean">
            <delete dir="${classes.dir}"/>
        </target>
        <path id="classpath">
            <fileset dir="${lib.dir}" includes="**/*.jar"/>
        </path>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
         <javac srcdir="${src.dir}"
          destdir="${classes.dir}"
          deprecation="on"
          debug="on">
       <classpath><path refid="classpath"/></classpath>
      </javac>
         </target>
         <target name="run" depends="compile">
       <!-- run the class -->
       <java classname="${runclass}">
            <classpath>
              <pathelement path="${classpath}"/>
              <fileset dir="${lib.dir}">
                <include name="**/*.jar"/>
            </fileset>
              </classpath>
           </java>
      </target>
         </project>i invoked
    ant runand got this
    Buildfile: build.xml
    compile:
    run:
         [java] Could not find TestClient. Make sure you have it in your classpath
         [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava
    .java:170)
         [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:710)
         [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:178)
         [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
         [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
    va:275)
         [java]     at org.apache.tools.ant.Task.perform(Task.java:364)
         [java]     at org.apache.tools.ant.Target.execute(Target.java:341)
         [java]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
         [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
    a:1216)
         [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
         [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
    faultExecutor.java:40)
         [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068
         [java]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
         [java]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
         [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
         [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
    BUILD SUCCESSFUL
    Total time: 2 secondsso, code is not running......its dfinitely a classpath problem , because error message says "Could not find TestClient. Make sure you have it in your classpat".
    TestClient is the name of main class file.
    not sure whats wrong with this build.xml ? whats wrong in it ?
    one thing , i guess, i did not mention "." , current directory in the build.xml ......is it because of that ?
    i browsed apache manual......To Run a Java program.....first, they are making a JAR file ...and then they are executing the JAR.
    i really, dont need the JAR file......i just want to run it.....thats enough.
    somewhere, i have to do some modification in this buld.xml.......do you have any idea ?
    thank you

    TestClient folder has
    1)src
    2)classes
    3)build.xml
    i have posted the build.xml already.
    now, src folder has TestClient.java
    TestClient.java
    ==================
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import javax.xml.namespace.QName;
    public class TestClient {
       public static void main(String [] args) {
         try {
           String endpoint =
               "http://ws.apache.org:5049/axis/services/echo";
           Service  service = new Service();
           Call     call    = (Call) service.createCall();
           call.setTargetEndpointAddress( new java.net.URL(endpoint) );
           call.setOperationName(new QName("http://soapinterop.org/","echoString"));
           String ret = (String) call.invoke( new Object[] { "Hello!" } );
           System.out.println("Sent 'Hello!', got '" + ret + "'");
         } catch (Exception e) {
           System.err.println(e.toString());
    }and i did
    ant runand i got those errors.
    clearly, its not able to run it.
    looked the manual....did not find anything special about java task....still not working.

  • Java program to run a C compiled file in SHELL unix

    hi,
    i have two queries,
    1) i have a c program which i compile to get a new file,{a exe file i suppose}, i need to execute it for 2000 times. for that i need to write a java program which can run the file in SHELL unix.
    can you suggest me how to write,
    2) also my file name starts with 0001.mnp to 1989.mnp, how to get 0001 as a number and during increment it should generate as 0002 ..0038 and so on. till 1989.
    the above java program which am goin to write should just take file 0001.mnp and convert it into 0001.bns,
    and get incremented automatically till the file 1989.

    hi,
    i have two queries,
    1) i have a c program which i compile to get a new
    file,{a exe file i suppose}, i need to execute it for
    2000 times. for that i need to write a java program
    which can run the file in SHELL unix.
    can you suggest me how to write,Read this: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    However, you could do this all in a shell script.
    >
    2) also my file name starts with 0001.mnp to
    1989.mnp, how to get 0001 as a number and during
    increment it should generate as 0002 ..0038 and so
    on. till 1989.
    the above java program which am goin to write should
    just take file 0001.mnp and convert it into
    0001.bns,
    and get incremented automatically till the file 1989.A loop? What are you having difficulty with?
    Again, this could all be done in a shell script.

  • Java program stopped running when using JVMPI

    Hi!
    I'm writting a very simple profiler using JVMPI. I intended to pause/continue it by sending signal, like kill -SIGUSR2 PID, to it, but whenever I did this, the java program that ran with the profiler stopped running, however the profiler kept running properly.
    Here's the code of the simple profiler and the testing java program.
    //myprofiler.cc
    #include <jvmpi.h>
    #include <pthread.h>
    #include <stdio.h>
    #include <signal.h>
    void sig_handler_pause(int);
    static JVMPI_Interface *jvmpi_interface;
    void notifyEvent(JVMPI_Event *event) {
    switch(event->event_type) {
    case JVMPI_EVENT_CLASS_LOAD:
    fprintf(stderr, "myprofiler> Class Load : %s\n", event->u.class_load.class_name);
    break;
    case JVMPI_EVENT_OBJECT_ALLOC:
    fprintf(stderr, "myprofiler>object alloc \n");
    break;
    extern "C" {
    JNIEXPORT jint JNICALL JVM_OnLoad(JavaVM jvm, char options, void *reserved) {
    fprintf(stderr, "myprofiler> initializing ..... \n");
    // get jvmpi interface pointer
    if ((jvm->GetEnv((void **)&jvmpi_interface, JVMPI_VERSION_1)) < 0) {
    fprintf(stderr, "myprofiler> error in obtaining jvmpi interface pointer\n");
    return JNI_ERR;
    // initialize jvmpi interface
    jvmpi_interface->NotifyEvent = notifyEvent;
    // enabling class load event notification
    jvmpi_interface->EnableEvent(JVMPI_EVENT_CLASS_LOAD, NULL);
    fprintf(stderr, "myprofiler> .... ok \n\n");
    signal(SIGUSR2,sig_handler_pause);
    return JNI_OK;
    void start(){
              fprintf(stderr,"start...\n");
         jvmpi_interface->EnableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL);
    jvmpi_interface->EnableEvent(JVMPI_EVENT_CLASS_LOAD,NULL);
    void pause(){
              fprintf(stderr,"pause...\n");
              jvmpi_interface->DisableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL);
    jvmpi_interface->DisableEvent(JVMPI_EVENT_CLASS_LOAD,NULL);
    int status=0;
    void sig_handler_pause(int sig){
         if(status == 0){
              start();
              status = 1;
         else if(status == 1){
              pause();
              status = 0;
    //Test.java
    public class Test {
    public static void main(String[] args) {
         try {
                        int i = 0;
    while(true)
                             Thread.sleep(1000);
                        System.out.println(i++);
              catch (Exception e) {
                        e.printStackTrace();
    Here're some notes:
    1)If I didn't call
    jvmpi_interface->EnableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL);
    in "start()" function, the java program Test ran properly after I sent signal to the process by using kill command in an command line;
    or
    2) If I delete "Thread.sleep(1000)" in Test.java, then whether I call
    jvmpi_interface->EnableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL);
    in "start()" or not, the Test program ran properly after I sent signal to the process.
    It seems to be a thread dead lock, but I'm not sure. Can any body help?Thanks very much.

    I should strongly recommend moving from JVMPI to JVM TI if you can. The reason is that JVMPI has been deprecated since 5.0 and can not be used with Java SE 6 and newer.
    Anyway, the issue you have may be due to the signal you are using. I'm not sure which operating system this is but on Linux the USR2 signal is used for the suspend/resume implementation. Have you looked at the Troubleshooting Guide or the Signal Chaining page for details on how signals are used and how to chain handlers? Another idea is to remove the signal handling code implementation and to use the data dump event. This is supported by both JVMPI and JVM TI so that you get an event (via the QUIT signal).

  • How to find that a java program is running for the first time on daily basi

    it is like this
    1. i will ran a java program every day and i have to find that it is running for the first time(as i may stop that program and may run again the same day )
    Pls share ur ideas

    san.kumar wrote:
    it is like this
    1. i will ran a java program every day and i have to find that it is running for the first time(as i may stop that program and may run again the same day )
    Pls share ur ideasAs kajbj said - you need to store a token / file with a run date on the file system. Each time the application runs, have it compare with the date from this file with the current date. If different, it's the first run of the day. If not, it is not the first run of the day. Each time have it update the date on the file.

  • How do I get a program to run inside flash

    How do I get a program on my harddrive to run inside flash on my computer? I would like to build a Flash front end for my boat pc, but I would need to be able able to open up a program inside a flash.exe?
    would a external .ini  File work? if so what code would I use internally to execute the .ini
    any help would be greatly appreciated Sincerely newwaveboats

    Thanks for the tip about Zink, but it is not what I'm after.
    On (Release)
    FS Command ("exec", "install.exe")
    End On
    google search just revealed this button code but it was for back in the day "Flash 8" as1 or 2.  as3 your not allowed code to be plaaced on buttons.
    So I know it is possible, I just need the know how.
    EDIT: I looked further into to this, and it is perfect for my needs. my first look was quick and I saw a close to 300 price tag and that it was a compiler, 2nd longer look showed it was free for personal use and has lots of great system features.
    Thanks again combustion007 for your help was greatly appreciated, Sorry I did not realize how perfect it was when you first told me about it.

  • How do I get my program to run at a faster frequency?

    I am using the PCI-DIO-32HS (6533) board. A portion of the program writes a pattern of various handshaking signals. The other clocks in a bit of data and formats the data into arrays. The spec. sheets say this board can do pattern I/O at 13Mbytes/s or handshake at 76Mbytes/s. I'm running a 733MHz processor with 128M of RAM. Even after changing the buffers any from 4-50 Million, the fastest I could get either part of the program to run individually was about 1MHz. Together, they top out at about 50KHz. What do I need to do to get this program to work at about 2MHz?

    William,
    Try running one of the examples that ship with LabVIEW that does pattern I/O or burst mode handshaking. One of the things to keep in mind is to eliminate as much programming in the DIO write loop as possible as this will slow down your program and your data transfer rate that is attainable.
    In LabVIEW the examples can be found under Search Examples -> I/O Interfaces -> Data Acquisition -> Digital I/O.

  • Java Program Not Running

    Hi,
    I have a small Java program that imports Oracle.sql.* and Oracle.jdbc.*.
    It establishes a default connection and converts a String[ ] to Oracle.sql.ARRAY type.
    As per Oracle documentation, I have added paths of required .zip files in CLASSPATH variable.
    Though I am able to compile the code, but when I try to run it thru java, it gives me error:
    Exception in Thread "main" java.lang.NoClassDefFoundError: TestInstallJDBC
    The .java and .class files are in current directory and I'm using
    java TestInstallJDBC.
    What can be the problem?
    Any help is appreciated.
    Thanks

    Ah, I re-read your first post - you said you added paths to the Classpath. So you need to add . to your Classpath as well. For Windows .;<existing_classpath> or for Unix .:<existing_classpath>

  • Java Program to run an https based url

    This is the simple code to read through a java program from a simple http based procot URL
    import java.net.*;
    import java.io.*;
    public class URLReader {
    public static void main(String[] args) throws Exception {
         URL yahoo = new URL("http://mail.yahoo.com/");
         BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        yahoo.openStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null)
         System.out.println(inputLine);
         in.close();
    But if i use the url https://mail.yahoo.com/ instead of http://mail.yahoo.com/ then i have an exception given below
    Exception in thread "main" java.io.IOException: HTTPS hostname wrong: should be
    <mail.yahoo.com>
    at sun.net.www.protocol.https.HttpsClient.b(DashoA12275)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(DashoA12275)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect
    (DashoA12275)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:626)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Dash
    oA12275)
    at java.net.URL.openStream(URL.java:913)
    at URLReader.main(URLReader.java:7)
    Now i want this program based on https to run. SO can anybody help me running the same program by using https? Or can anybody give me the code to run a url based on https protocol?

    Same as http://forum.java.sun.com/thread.jspa?threadID=677398&tstart=0 . Check reply on the other post.

  • I can't  get my program to run correctly

    I made a calculator but i can't get the values to update correctly. If you run my code you'll see what I'm talking about. The value number isn't updating and I can only enter in a double digit number (using the buttons) as the initial number. I think its a problem with my boolean statement, but I've tried everything I could think of and things only get worse. (I still haven't figured out the decimal button either.)
       import java.awt.BorderLayout; 
       import java.awt.Container;
       import java.awt.GridLayout;
       import java.awt.event.ActionEvent;
       import java.awt.event.ActionListener;
       import java.awt.event.WindowAdapter;
       import java.awt.event.WindowEvent;
       import javax.swing.JButton; 
       import javax.swing.JFrame;
       import javax.swing.JLabel;
       import javax.swing.JPanel;
       import javax.swing.JScrollPane;
       import javax.swing.JTextArea;
       import javax.swing.JTextField;
       public class CalculatorFrame4 extends JFrame
          public CalculatorFrame4()
                   JPanel calculator=new JPanel();
                   mainPanel();
                   pack();
              public void mainPanel()
                   number=0;
                   nextNum=0;
                   result=0;
                   operator="=";
                   start=true;        
                   numberField =new JTextField();
                   numberField.setEditable(true);
                   final JButton button1 =new JButton("1");
                   final JButton button2 =new JButton("2");
                   final JButton button3 =new JButton("3");
                   final JButton button4 =new JButton("4");
                   final JButton button5 =new JButton("5");
                   final JButton button6 =new JButton("6");
                   final JButton button7 =new JButton("7");
                   final JButton button8 =new JButton("8");
                   final JButton button9 =new JButton("9");
                   final JButton button0 =new JButton("0");
                   final JButton divbutton =new JButton("/");
                   final JButton multbutton =new JButton("*");
                   final JButton minusbutton =new JButton("-");
                   final JButton plusbutton =new JButton("+");
                   final JButton decbutton =new JButton(".");
                   final JButton equalsbutton =new JButton("=");
                   class NumberListener implements ActionListener
                        public void actionPerformed(ActionEvent event)
                             Object source =event.getSource();
                             if (start)
                                  if (source == button1)
                                       numberField.setText(numberField.getText()+1);                                   
                                  else if (source == button2)
                                       numberField.setText(numberField.getText()+2);
                                  else if (source == button3)
                                       numberField.setText(numberField.getText()+3);
                                  else if (source == button4)
                                       numberField.setText(numberField.getText()+4);
                                  else if (source == button5)
                                       numberField.setText(numberField.getText()+5);
                                  else if (source == button6)
                                       numberField.setText(numberField.getText()+6);
                                  else if (source == button7)
                                       numberField.setText(numberField.getText()+7);
                                  else if (source == button8)
                                       numberField.setText(numberField.getText()+8);
                                  else if (source == button9)
                                       numberField.setText(numberField.getText()+9);
                                  else if (source == button0)
                                       numberField.setText(numberField.getText()+0);
                                  number=Double.parseDouble(numberField.getText());
                             else
                                  numberField.setText("");
                                  if (source == button1)
                                       numberField.setText(numberField.getText()+1);
                                  else if (source == button2)
                                       numberField.setText(numberField.getText()+2);
                                  else if (source == button3)
                                       numberField.setText(numberField.getText()+3);
                                  else if (source == button4)
                                       numberField.setText(numberField.getText()+4);
                                  else if (source == button5)
                                       numberField.setText(numberField.getText()+5);
                                  else if (source == button6)
                                       numberField.setText(numberField.getText()+6);
                                  else if (source == button7)
                                       numberField.setText(numberField.getText()+7);
                                  else if (source == button8)
                                       numberField.setText(numberField.getText()+8);
                                  else if (source == button9)
                                       numberField.setText(numberField.getText()+9);
                                  else if (source == button0)
                                       numberField.setText(numberField.getText()+0);
                                  nextNum=Double.parseDouble(numberField.getText());
                   ActionListener listener =new NumberListener();
                   button1.addActionListener(listener);
                   button2.addActionListener(listener);
                   button3.addActionListener(listener);
                   button4.addActionListener(listener);
                   button5.addActionListener(listener);
                   button6.addActionListener(listener);
                   button7.addActionListener(listener);
                   button8.addActionListener(listener);
                   button9.addActionListener(listener);
                   button0.addActionListener(listener);           
                   class CalculateListener implements ActionListener
                        public void actionPerformed(ActionEvent event)
                             numberField.setText("");
                             Object source=event.getSource();
                             if (source==divbutton)
                                  operator="/";
                             else if (source==multbutton)
                                  operator="*";
                             else if (source==plusbutton)
                                  operator="+";
                             else if (source==minusbutton)
                                  operator="-";
                             else if (source==equalsbutton)     
                                  operate(nextNum);
                                  numberField.setText(""+number);
                             start=false;
                   ActionListener calclistener =new CalculateListener();
                   divbutton.addActionListener(calclistener);
                   multbutton.addActionListener(calclistener);
                   plusbutton.addActionListener(calclistener);
                   minusbutton.addActionListener(calclistener);
                   equalsbutton.addActionListener(calclistener);
                   JPanel controlPanel = new JPanel();
                   controlPanel.setLayout(new GridLayout(4, 4));
                 controlPanel.add(numberField);
             controlPanel.add(button7);
             controlPanel.add(button8);
             controlPanel.add(button9);
                   controlPanel.add(divbutton);
               controlPanel.add(button4);
             controlPanel.add(button5);
             controlPanel.add(button6);
                   controlPanel.add(multbutton);
                   controlPanel.add(button1);
             controlPanel.add(button2);
             controlPanel.add(button3);
                   controlPanel.add(minusbutton);
                   controlPanel.add(decbutton);
             controlPanel.add(button0);
             controlPanel.add(equalsbutton);
                   controlPanel.add(plusbutton);
             JPanel clearPanel = new JPanel();
                   final JButton clearbutton =new JButton("CLEAR");
             clearPanel.add(clearbutton);
                   class ClearListener implements ActionListener
                        public void actionPerformed(ActionEvent event)
                             number=0;
                             nextNum=0;
                             numberField.setText("");
                 ActionListener alistener =new ClearListener();
                   clearbutton.addActionListener(alistener);
                   getContentPane().add(numberField, BorderLayout.NORTH);
             getContentPane().add(controlPanel, BorderLayout.CENTER);
             getContentPane().add(clearPanel, BorderLayout.SOUTH);
              public void operate(double otherNum)
                   if (operator.equals("/"))
                        number = number/otherNum;
                   else if (operator.equals("*"))
                        number = number*otherNum;                                
                   else if (operator.equals("+"))
                        number = number+otherNum;
                   else if (operator.equals("-"))
                        number = number-otherNum;
              private boolean start;
              private double number;
              private double nextNum;
              private double result;
              private String operator;
              private JTextField numberField;
         }Here's the test program
       import javax.swing.JFrame;
       public class CalculatorTest
          public static void main(String[] args)
             JFrame frame = new CalculatorFrame4();
             frame.setTitle("Calculator");
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.show();
       }

    I am no expert, in fact I am a very newbie. But I was trying to get my code to update too, and I didn't know I had to call the validate() function...try doing that, if you haven't already, also read up on validate() from the Component (or Container) API. I didn't really look through your code, I wouldn't be able to keep it in my head anyway.

  • Can't get java applet to run on IE 6.0

    I have just installed j2sdk1.4.0 and I am trying to get the HelloWorld example to run. I can get it to run on appletviewer but when I run in on IE 6.0, I get the error message
    Error loading class: HelloWorld
    java.lang.ClassFormatError
    java.lang.ClassNotFoundException: HelloWorld
    I have tried other java applets from various websites and they work.
    Can anyone please help me?

    Download and Install Java Plugin and Use the OBJECT tag instead of the APPLET tag.

  • Cannot get java window to run at all.

    I'm using 1.4.2, and cannot get any java to run at all. It's on a Windows 2000 server, and I've rebooted it a few times. Can't even get the Java Applet window to open from the control panel. javaw.exe runs in the task manager, but that's it. Any ideas? Anything else I need?

    That's the Java Control Panel you can't open.
    Try uninstalling ALL Java versions, rebooting after each uninstall, and manually removing any directories that Java made after all are removed. Reboot again, then download a new offline Java installer file and install that. There's something in the machine that's bad.

Maybe you are looking for

  • Travel Cost Distribution

    We are having two company codes here, 1000 and 2000. Employees belong to either of them. If an employee belongs to company code 1000, and he makes allocation of his cost 100% to a cost centre that belongs to company code 2000, we are having no proble

  • Flash Player sound problems on a 5.1 system

    I don't know if i found the right topic for asking for this question, but here it goes. I noticed that flash player has this issue with my 5.1 system, when i play music (and i mean any music, like my online radio, played through flash, or music throu

  • Developement overview / monitoring in Solution Manager

    Hello all, I'm novice in Solution Manager and I don't know if my requirements are feasible. I created a structure in SolMan, I found out how to uploaded "development specification" into Proj.documentation tab. Even the statuses for documents are OK.

  • Tables not showing as desired

    Hi...thanks for readling...appreciate... Having a tables issue: As one can see from the screen grabs, the table view shows the floral graphic coming right under the text....just over to the side. However, in the Live View, the floral is quite a bit f

  • Iweb crashes when I save

    I have just updated some pages on my existing website and successfully published the site. However when I went to save the changes it says 'The document "Domain.sites2" could not be saved.' So I reebooted and tested by making 1 or 2 amendments, selec