Can't run java program with GUI

My computer can run java program properly.
However, for those program with GUI (using swing),
my computer is unable to display the GUI.
What's wrong with it? Is there any PATH I need to set before running GUI program?
Thanks
icedgold

Cut, copy, paste then compile and run this;-import java.awt.*;
import javax.swing.*;
public class MyJFrame extends JFrame {
  public MyJFrame() {
      super("My first JFrame");
      Container c  = getContentPane();
      JPanel panel = new JPanel();
      panel.setBackground(Color.white);//  (new Color(255, 255, 255));
      JLabel jl = new JLabel("Yes it works");
      panel.add(jl);     
      c.add(panel);
  public static void main(String[] args) {
    MyJFrame frame = new MyJFrame();
    frame.setSize(180,120);
    frame.setLocation(200, 300);
    frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
    frame.setVisible(true);
}

Similar Messages

  • Can't Run Java Programs -- java.lang.NoClassDefFoundError Error

    I am running 10.4.11. For some reason I can no longer run Java programs. (I could in the past)
    For example. I create a simple Hello World program as follows and save it as Hello.java:
    class HelloWorld
    public static void main (String args[])
    System.out.println("Hello, world!");
    Then I compile it:
    Javac Hello.java
    Then I try to run it:
    java Hello
    But I get this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: Hello
    I think it must be a CLASSPATH problem but normally you do not need to worry about ClassPATH. Apple sets it up for you out of the box.
    What is wrong?

    I totally forgot that the class name should be the same as the filename.
    After I renamed the file to HelloWorld.java and recompiled, I could run "java HelloWorld"
    Rob

  • Running java program with arguments in Unix

    Hi
    I am a new newbie to java so pardon if this is too simple for you .
    This is my scenario. I have a java program which parses an xml and writes a .dat file. I execute this testparser.java in unix environment like this
    java testparser xml1.xml
    and it retuns me a .dat file
    But my issue is I have to run my parser program for 40 xml files. The requirement is I have to create a script file and possibly with a for loop which will loop through 1-40 xml files and return me the .dat file.
    I am really at a loss here. I am new both to Java and Unix
    So pls help me out
    Thanks in Advance
    G

    You could just do this in Java. Make it take all 40 xml files on the command line, and convert them all with one program invocation.
    If you want to do it in shell script, you can do something like
    for tmp in `ls -1 *.xml`; do
      java testparser $tmp
    donedepending on your shell, etc.

  • Can i run java program in the same way of .exe program?

    I am beginner in java and i'd like to know that java program can run in the same of .exe program(double click program icon) , instead of typing "java [class name]" or
    choose execute botton from forteCE.
    Thank you for your help
    [email protected]

    You can write a .bat script which launches the java command for you:
    @echo off
    java <your prog name here>
    Then move your .bat file icon wherever you want...
    bye
    Michele
    Tip: if you don't want to see the black VM window, try javaw instead of java.

  • Can't run java programs

    I'm having trouble getting java programs to run on my computer. I have no problem compiling programs but whenever i try to run them through the command prompt window i get the following error:
    Exception in thread "main" java.lang.NoClassDefFoundError: hello
    where 'hello' is the name of the 'hello world' test program i made (just prints the words 'hello world' world on screen.)
    The programs run on eclipse but i really prefer using the good old command prompt window. Can anyone explain to me what's wrong here (I'm guessing it's some sort of windows/java sdk setting that must be off.) Thanks in advance!!!

    I thought that this was resolved a couple days ago but apparently it wasn't (it was the temporary fix that was working.)
    I still get the same noclasseffounderror whenever i try to run the java program. The link tells me to add the correct 'path' to the system folder to make it work. It's actually already there (otherwise the javac command wouldn't work either.) However, the java programs do run whenever i execute the command
    set classpath=
    However, i have to do this every single time i open up a new shell window. Anybody know what the problem could be given that it works when i 'clobber it into working' as the tutorial put it?

  • Can't run Java Programs from home computer

    Hi, sorry if this is a simple problem.
    I downloaded Java version 1.4.0_03 but can't get it to work. I have configured the PATH variable and the CLASSPATH but it isn't working.
    If I type java -version the right stuff comes up.... so where have I gone wrong?
    Any ideas much appreciated
    Thanks
    cat

    I downloaded JDK
    this is whats in the PATH variable:
    ;C:\Program Files\Java\j2re1.4.0_03\bin
    and in the CLASSPATH:
    .;C:\Program Files\PhotoDeluxe HE 3.0\AdobeConnectables;C:\Program Files\Java\j2re1.4.0_03\lib\tools.jar

  • Can't run java apps with System.out.println on any builder.

    Hello,
    I'm currently using Vista RC2, which is the immediate problem.
    Classes with System.out.println won't launch the console window. As I'm a student and practicing on these steps, I do have quite a problem on my hands. I click on run, build succesfull, nothing happens.
    I have tried Netbeans and Jcreator, and gave up on trying different builds, as I reckon I'll have to find some other way to counter this; any way to get println messages working in vista?

    It is run as a desktop app, and other runs with commands such as JOptionPane do function, only the println windows don't appear at all. So I think JRE is installed and working.
    I did notice there was one command for input where I'd be able to enter it at the bottom of Netbeans.
    Like just now I clicked build and run for the following code
    import java.util.*;
    public class FirstProgram
        public static void main(String[] args)
            System.out.println("Hello out there.");
            System.out.println("I will add two numbers for you.");
            System.out.println("Enter two whole numbers on a line:");
            int n1, n2;
            Scanner keyboard = new Scanner(System.in);
            n1=keyboard.nextInt();
            n2=keyboard.nextInt();
            System.out.println("The sum of those two numbers is");
            System.out.println(n1+n2)
    }Resulting in a brief flash of "input" in the output window (which is below the coding window) and it dissapears. But this also occurs when I don't include system scanner code.
    Using commands in cmd
    java -jar "C:\Users\Alegis\Netb\MyApp\dist\MyApp.jar"
    Does not yield desired results either. Nothing happens.

  • Can a running java program reset itself internally so it ...

    so it behaves just as if it was run for the first time!
    Thank you

    Something like this?Runtime.getRuntime().exec("java thisClass");
    System.exit(0);

  • How to run the program with variant automatically

    Hi experts,
    I want to know how can I run the program with a variant automatically without defining any transactions or jobs. I want my program to run with a variant automatically, when I press F8.

    Try doing this way...
    First Create a Sel Screen varient, 'ZTEST123' in this case
    Report ZTEST.
    parameters:
      w_kunnr type kna1-kunnr,
      w_flag type c no-display.
    start-of-selection.
    if w_flag eq ' '.
      submit ZTEST USING SELECTION-SET 'ZTEST123' with w_flag eq 'X'.
    endif.
    end-of-selection.
      write:  w_kunnr.
    Thanks.

  • Running java program as a server

    Please advise of what's difference in running java program with -server option and just runing it like java program1?
    Thx

    -server option uses the server VM for the program and if you use -client it will be run using client VM. Default is client.
    The main difference is the optimations. When you are running with -client option the program is optimized to startup faster and to give better response times.
    -server option optimizes for better resourse management which is important than start up time in server systems

  • Why can't I run my Java program with just the JRE, the JDK is required?

    I've recently written 3 programs in Java using the Netbeans IDE with JDK 1.6 as the default Java platform. The compile-time libraries include the Swing Application Framework. I use BuildDesk from ProductiveMe to package the each program into a Windows installer.
    When I install the programs on a new computer without a JRE or JDK being present, and attempt to run them I get an error (as expected) stating that there is no JVM. The messages says that I need to install JDK 1.3 or higher. I downloaded the latest JRE onto the new computer and attempted to run the programs and I get the same error message. My question is, why can't I run these programs with just the JRE installed? Why do I need the JDK? When I install the JDK, the programs run fine. The typical user may not have the JDK on their system, but they likely have the JRE if they've run Java programs before.
    Is the answer as simple as there must be library functions being used by the programs that belong to the JDK, but not the JRE? I'd rather a user not have to install the JDK verses the JRE because they may also have to update some Windows environment variables.
    Thank you for any help on this issue.

    915088 wrote:
    Thanks for your replies. I further investigated BuildDesk and found an option which allows a JVM check but that check needs the JDK. I stopped the JVM check and rebuilt using BuildDesk and it now only requires the JRE to run the programs. The reason why I use BuildDesk is to package more than just the jar file for the user. BuildDesk allows me to create a installation folder structure as well as include any other files in the build. I could just as well zipped all this together for the user but decided against that method.I don't think anyone will question your usage of an installer tool; that is entirely up to you. But what is questionable is that you have problems with that installer tool and then go look for help in a Java programming forum. The next time, go look for help at the source. If there is no way to acquire help (support, a forum, a mailinglist, anything) then that is a very good reason to not use the product in question.

  • How can i run my java program with out java language

    Hai to every one ..Iam new to java language ...am using windows xp operating system , i did not installed java language in my system .. how can i run a java program with out installing java language... Which files is requied to run java program..?
    any one can help me??

    Hai to every one ..Iam new to java language ...am
    using windows xp operating system , i did not
    installed java language in my system .. how can i run
    a java program with out installing java language...
    you ... can ... not ... do ... this
    Which files is requied to run java program..?
    any one can help me??a JVM. Download it from sun's website.
    [url http://java.sun.com/javase/downloads/index.jsp]Download JavaSE here

  • How to run a standalone java program with JRC to display/run a report

    Hi All,
    I am new to this forum.
    I am trying to run a java program developed using JRC to run a report created using Crystal Report XI. I stucked because not knowing how to run that java program.
    Can anyone help me? or
    can give a simple java code to do the same.
    Thanks in advance.
    Saravanakumar.

    Hi Saravana
    For the steps to run a standalone application java program with JRC to display/run a report ,please refer the following link.
    http://support.businessobjects.com/communityCS/TechnicalPapers/cr_xi_r2_jrc_deployment.pdf.asp
    You can get the sample code for standalone/desktop applications from the following link.
    http://support.businessobjects.com/communityCS/FilesAndUpdates/crxi_r2_jrc_desktop_samples.zip.asp
    Please do revert in case of any queries.
    Thanks
    Soni

  • Can we able to run java program inside  javascript

    Hi all
    can we able to run java program inside javascript or integrate java with javascript.....whether its possible...

    No. You can't execute Java code from within a JS script in Acrobat/Reader.

  • How to run java program from website?

    Hello
    I'd like to know how to run java program from my web page.
    I'd like to push some button in this web page so java program that would be on my server
    would pop-up. Can it be done automaticaly upon running this web site? (without any buttons - I just enter website and program pops up).
    Cheers

    I rather thought about RMI. But I could try servlets. So how it would look like?.
    I would make http request in browser (enter address) and program would show up in its window?. And I would not have to change anything in my program?. This program would run then on both boxes?. One remotely and one not?.
    But I would have to learn some basics, I've never worked with servlets. Could you suggest some good sites about it?. With ready examples so I could tweak them to my purpose.
    Message was edited by:
    macmacmac

Maybe you are looking for

  • Satellite A200 (PSAE6) Cannot dowload BIOS update

    Hi! I have some kind of problem. I want to upgrade my BIOS, but i can't dowload it from dowload page! Maybe I can dowload it from somewhere else?

  • How to create web page containing a text(Information)  in webcenter portal

    Hi I want to create a web page containing a text (information)and that should be editable at run time.I am trying the same to achieve through oracle composer but unable to get the required result. I am using J developer 11g for creation.

  • How to disable a input field in OVS search

    Hi friends, I have crated a OVS search help for matnr. i have two input field like matnr and mat desc.. user can enter any value and hit SEARCH.. im getting results. Now i want to hardoced a value of matnr = 001.. and make this field read only.. how

  • R/3-XI-SUS

    Hello Friends, I trying to send a PO from R/3 to SUS via XI. From the XI the message is transmitted successfully to SUS. But in SRM Moni I am getting an error message  as <SAP:Stack>Error during proxy processing An exception with the type CX_BBPX1_ST

  • Problem with FETCH

    If you have a fetch statement inside of a LOOP like below, should it fetch the NEXTVAL or have I missed something? When I run this I get a unique constraint violated (order_id is PK) declare cursor next_order_id is select seq_order_id.nextval from du