Running Swing Program

I recently upgraded to 1.4.2_03 to use regexp. After the upgrade when I try to run a java class which should
display a frame the program hangs. If I use the 1.3.1 SDK everything works fine. Does anyone know what the problem might be.
//Here is a snippet
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/* FrameDemo.java requires no other files. */
public class TestFrame {
     /**     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.     */
     public static void createAndShowGUI() {
          //Suggest that the L&F (rather than the system)
          //decorate all windows.  This must be invoked before
          //creating the JFrame.  Native look and feels will
          //ignore this hint.          System.out.println("setting feel");
          //JFrame.setDefaultLookAndFeelDecorated(true);
          //Create and set up the window.
          JFrame frame = new JFrame("FrameDemo");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          System.out.println("Jframe created");
          JLabel emptyLabel = new JLabel("");
          System.out.println("JLabel Created");
          emptyLabel.setPreferredSize(new Dimension(175, 100));
          frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
          System.out.println("JLabel added to content pane");
          //Display the window.//        frame.pack();//
          System.out.println("JFrame packed");
          frame.setSize( 700, 300 );
          System.out.println("JFrame size set");
          frame.setVisible(true);
          System.out.println("JFrame visible");
          public static void main(String[] args) {
                          //Schedule a job for the event-dispatching thread:
          //creating and showing this application's GUI.
          javax.swing.SwingUtilities.invokeLater(new Runnable() {
          public void run() {
                         System.out.println (System.getProperty ("java.version"));
                                                          createAndShowGUI();
}

Ok here it is, I just couldn't sleep until I had an answer. It was a service running, awhost32.exe which
is PCAnywhere host service. The first thing I did was shut down all of the services that were not part of the OS. ThenI tried my test application and it worked. Then I started the services I had shut down one at a time until I found the one causing the problem.
I hope this will help anyone having a similar problem.

Similar Messages

  • Error while running Swing program on FreeBSD

    Hi,
    I am trying to run simple swing program "helloworld"
    but while executing it gives following error on FreeBSD
    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    /usr/local/linux-sun-jdk1.4.2/jre/lib/i386/libawt.so: libXp.so.6:
    cannot open shared object file: No such file or directory
            at java.lang.ClassLoader$NativeLibrary.load(Native Method)
            at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1477)
            at java.lang.Runtime.loadLibrary0(Runtime.java:788)
            at java.lang.System.loadLibrary(System.java:834)
            at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
            at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
            at java.awt.EventQueue.<clinit>(EventQueue.java:80)
            at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1170)
            at JPanels.main(JPanels.java:29)
    Should i install XFree86-libs package on FreeBsd
    configuration
    FreeBSD 4.10-BETA (GENERIC)
    I am using following packages
    linux-sun-jdk-1.4.2.04 Sun Java Development Kit 1.4 for Linux
    linux_base-8-8.0_4 Base set of packages needed in Linux mode (only for i386)
    linux_devtools-8.0_1 Packages needed for doing development in Linux mode
    libtool-1.3.5_1 Generic shared library support script
    gmake-3.80_1 GNU version of 'make' utility
    automake-1.4.5_9 GNU Standards-compliant Makefile generator (legacy version
    GCC 2.95.4
    gdb 4.18
    ld 2.12.1 supported emulation elf_i386
    regards
    Man479

    This is not really a Swing question. You should install the library which satisfies the lookup of libXp.so.6 .
    I quess the jre for this platform is compiled against this version. Looks to me like some X related library, maybe google can resolve a solution/package to install?
    Greetz

  • Running Swing programs on Mac system

    Hi,
    I am using j2sdk1.4 version (jre 1.4) on windows system and developed application using swing.
    I wanted to test this applicaion on Max 8.1 later.
    will this work or I need to install different version of j2sdk on windows (which is supprted by mac ) and run the application?
    Thanks,
    padmashree

    mac os just supports JRE 1.3. at version 10.

  • Compiling and Running Swing Programs - can't execute tutorial

    Hi,
    Help is appreciated! :)
    I'm new to java and I'm following [this tutorial|http://java.sun.com/docs/books/tutorial/uiswing/start/compile.html] (I've pasted the code below after the error message.)
    I'm on Opensuse 11 / KDE4. Here's my output for java -version
    java version "1.6.0_06"
    Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
    Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)
    I pasted the code in an editor, saved it in a temp directory as HelloWorldSwing.java
    In the console at the temp directory, I compiled without problems with "javac HelloWorldSwing.java"
    Two .class files are generated, HelloWorldSwing$1.class & HelloWorldSwing.class
    The tutorial says I can then run the app with "java HelloWorldSwing", but I get the following error.
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldSwing (wrong name: start/HelloWorldSwing)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    package start;
    * HelloWorldSwing.java requires no other files.
    *import javax.swing.*;       
    public class HelloWorldSwing {
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("HelloWorldSwing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Add the ubiquitous "Hello World" label.
            JLabel label = new JLabel("Hello World");
            frame.getContentPane().add(label);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

    stringchopper wrote:
    I have to execute the file from a parent (project) directory all the time? if the class files are in /temp/start/ , I have to be in /temp and type:
    java start/HelloWorldSwing
    Well, you have to give the fully qualified CLASS NAME. Since your class is in a package named start, you have to specify start/HelloWorldSwing because that is your class' fully qualified name. Java has to manage class namespace and this is part of scheme. Also, while Java can use / or . as the package name separator character, it seems common that people use the period (start.HelloWorldSwing). In my view, this heps re-enforce the fact that it is a class name, not a file path.
    And, I have to have a directory named literally for my package name ("start"... "blah" won't work).
    Yes. Just like you can have different files with the same name in different directories, you can have different classes with the same name in different packages. And just like you can not have files with the same name in the same directory, you can not have the same class name in the same package.
    Why would the tut indicated running from the package directory? Perhaps something else isn't right on my system(?)
    If there is no system Classpath set, the current directory is the default Classpath.
    From the command line, it is common to use the -cp switch.java -cp /usr/myclasses mypackage.MyClass
    The link provided mentioned "echo $CLASSPATH"... mine came up empty. I've previously installed JDK and Netbeans - should I be concerned about how Netbeans will work if I set up a CLASSPATH system var?I can't help you with Netbeans but I believe most IDEs use their own method to find classes.

  • Need server to run swing program with oracle as back-end

    If I want to create a stand-alone program using swing and jdbc. What kind server I need?

    what do you mean distribute the application on the network? If it is a stand alone application then it is not a distributed application. Do you mean distributing the actual application to the users?

  • Urgent ! how to run swing from dos

    hi
    how should i run swing program through dos prompt.when found in i tried compiling from c:\jdk\bin i got an error "package javax.swing not import".
    viji

    what you willdo is this,
    at the top of your code type the line.
    import javax.swing.*;
    //for event type the next line..
    import javax.swing.event.*;
    import java.awt.event.*;
    I think this should solve your problem.

  • Running a Swing program from another program

    I'm having what is most likely newbie problems since I'm relatively new to Swing programming. Basically my situation is this: I've got a program that looks at its command line parameters and either runs through a series of actions or presents a Swing GUI to allow the user to step through the actions one by one.
    My problem is that I bascially don't know how to call (instantiate, declare, etc.) the GUI from my Java code. I tried implementing the GUI class with a runnable interface, but evertime I try to invoke the start on the interface I'm getting an error. I have a feeling I'm just missing something. The Swing GUI works fine if I call it on its own so it's the code the invokes it from the small command line processor that I'm goofing up somehow.
    So to recap, I have a small Java app that I'm trying to call a GUI that I've built and can't seem to get the code right.
    Any pointers to examples or explanation on how to accomplish the above are welcome.
    Thanks,
    Ed

    That the "2" is printed out immediately is as expected, but I don't understand why the JVM exits. The following is, AFAIK, a trimmed down version of what you are doing, and if you run it you'll see that the frame remains until you close it manually:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class ShowFrame {
        public static void main(String[] args) {
            AppFrame gui = new AppFrame();
            gui.run();
        private static class AppFrame extends JFrame implements Runnable {
            public AppFrame() {
                setDefaultCloseOperation(EXIT_ON_CLOSE);
                JButton btn = new JButton("Close");
                btn.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        AppFrame.this.dispose();
                getContentPane().add(btn);
                pack();
                setLocationRelativeTo(null);
            public void run() {
                System.out.println("1");
                this.setVisible(true);
                System.out.println("2");
    }Maybe someone else can shed some light over your problem...

  • 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);
    }

  • Problems in running SQLJ programs!

    Dear SQLJ Support,
    I am not able to run SQLJ programs. I am able to compile a .sqlj file.
    I tried to compile the demo programs, for example, TestInstallCreateTable.java. I get
    "Class oracle.sqlj.runtime.Oracle not found in import" error.
    "Class sqlj.runtime.ref.DefaultContext not found in import" error.
    When I try to run the other Demo programs also, I am getting errors at places where I import classes from translator.zip. Is there a problem with the JDBC Drivers?
    I have set the classpath set to
    ORACLE_HOME/sqlj/lib/translator.zip, where the classes are found
    ORACLE_HOME/jdbc/lib/classes111.zip, where the JDBC classes are found
    JAVA_HOME/lib/classes.zip, where the core java classes are found
    I am using Oracle 8.1.6, SQLJ 8.1.6, JDK 1.1.8 on Windows NT 4.0.
    Am I missing something else? Kindly advice. Thanks in advance.
    Regards,
    Radha.

    You might wanna try changing the Look and Feel of the swing application. Test it on default, Windows, Mac and Motif interface.... and do post if it works on changing the look and feel.
    cheerz

  • Placing a telnet session within a java swing program

    I was wondering if there was a way to maybe anchor a telnet session into a JPanel within a Java Swing program. Most of my users end up running a telnet session while using my Swing Program and I was hoping to find a way to bring the two together. If this is possible could someone point me in the right direction (like an online resource) that might show me how to do this.

    You could use sockets and a TextArea and build your own simple telnet application.
    Socket tutorial: http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

  • Swing program - how to increase the size

    Hi Friends,
    I have made a simple swing program and it works fine.But I am not able to make the size(width,height) of the panel.Can someone please tell me how can i do that.Here's some part of my code...
    public class Test extends JPanel
                                 implements ActionListener {
        //instance variable declared here
        public Test() {
            super(new BorderLayout());
            //code for buttons,labels etc
            JPanel buttonPanel = new JPanel(); //use FlowLayout
            add(buttonPanel, BorderLayout.PAGE_START);
        public void actionPerformed(ActionEvent e) {
            //lots of code
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("Test");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new Test();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }Thanks for your help.

    OK sorry for that,in future i will post it in the right place.I tried doing this but didn't worked:
           JPanel buttonPanel = new JPanel(); //use FlowLayout
           // buttonPanel.setSize(300, 300);I was followin the FileChooserDemo example from this link:
    http://java.sun.com/docs/books/tutorial/uiswing/components/examples/index.html#FileChooserDemo
    And they used the pack there....now can you help please.

  • Running two program instances

    Please help!!!
    I am developing a swing program which communicates modem via serial port. I used javax.comm package in the program. After coding, I compile all the class file into a jar file and use a .bat file to execute the program. If I just run one instance of the program, everything seems fine. But if I launch another instance of the program, problems occur. Only one set of swing components appear on two instance, either on one or on another. (i.e. the interface contains one button, one label and one textField. After I launch two instances, one instance's interface may contain the button and the label and another instance may contain just the textfield.). Upon closing the program, a log file was saved. The log as follow:
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6d043c7a
    Function name=Java_sun_java2d_loops_DefaultComponent_IntIsomorphicCopyLibrary=D:\jdk1.3.1_01\jre\bin\awt.dll
    Current Java thread:     at sun.java2d.loops.DefaultComponent.IntIsomorphicCopy(Native Method)
    javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
    # The exception above was detected in native code outside the VM
    # Java VM: Java HotSpot(TM) Client VM (1.3.1_01 mixed mode)
    Any help will be appreciated.
    William

    Thank you very much for your response.
    I compressed my program into a .jar file. The batch file I used contains "javaw.exe -jar Diagnostic.jar" to execute the program.
    According to the log file, It must have an execption that the program does not catch.
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6d043c7a
    Function name=Java_sun_java2d_loops_DefaultComponent_IntIsomorphicCopy
    Library=D:\jdk1.3.1_01\jre\bin\awt.dll"
    But I really don't know where it is and how to avoid it. Please help.
    William

  • What is the best spec to run multiple programs with photographs?  Includes:  Lightroom, PhotoMechanic, and Internet DAM system?

    What is the best spec to run multiple programs with numerous photographs?  Includes:  Lightroom, PhotoMechanic, and Internet DAM system?
    For a Macbook Pro.  What's the least amount I need to process, upload, download images using these 3 programs?
    Thank you.
    pt

    That's a nice system Kevin, and it will work very nicely with Photoshop.  I do take it that you have 16Gb RAM in Total?
    250Gb SSD is a good size, but you can still run short, and that will affect Windows performance.  When you get your system, instal WinDirStat which gives you a graphic display of everything on your drive, like below. Clicking on any of the large areas will tell you what and where they are, so you can think about moving cache folders etc. to one of the HDDs.
    Leave the Pagefile.sys on the boot drive.  Think about disabling Hyphenate as it takes a ton of space, and too often crashes on wake up.
    My Documents
    Desktop
    Downloads
    Look at Bridge cache
    iTunes backup
    Other stuff like that.
    Think about another 500Gb drive just for Photoshop Scratch.  Drives are cheap as chips nowadays
    Do yourself a favour, and invest $100 in Shadow Protect (or similar if there is such a thing) SP saves incremental backups every 15 minutes (you can set the interval, but it has no impact on performance with a system like yours).  If you have a problem you can mount the back up at any of those 15 minute points, and open files from it.  You can also make a bootable DVD image of your C drive, and be back up and running five minutes after disaster strikes.
    Optimize Performance in Photoshop
    Photoshop CC and CC 2014 GPU FAQ
    For more ideas, swing by the Premiere Pro Hardware forum.  Those guys are serious good at this stuff, and you'll find links tips and ideas.
    Happy computing, and have fun with your Creative Cloud® apps.

  • Error on compling the Swing program

    Hi all,
    I am trying to run a Login Swing program. I am want to go to the next page on click of the LOGIN button.Here is my code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class login extends JFrame implements ActionListener {
         public login(){
              setTitle("Login Page");
              //setSize(500,500);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
              Container pane = getContentPane();
              FlowLayout layout = new FlowLayout();
              pane.setLayout(layout);
              JLabel loginId = new JLabel("LoginId : ", JLabel.CENTER);
              JTextField Id = new JTextField(20);
              if(Id.equals("shri"))
                   System.out.println("login successful");
              JLabel password = new JLabel("Password : ", JLabel.CENTER);
              TextField pwd = new TextField(20);
              pwd.setEchoChar('*');
              JButton Enter = new JButton("Log in");
              private void actionPerformed(ActionEvent e)) {
                   String read = Id.getText();
                   String in = new String(pwd.getText());
                   //validate login and password here. validity will be done by sending login/password to the server
                   if (read.equals("Shri") && in.equals("Shri")) {
                   System.out.println("login successfull");
                   } else {
                   JOptionPane.showMessageDialog(this,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE);
                   Id.setText("");
                   pwd.setText("");
                   Id.requestFocusInWindow();
              pane.add(loginId);
              pane.add(Id);
              pane.add(password);
              pane.add(pwd);
              pane.add(Enter,BorderLayout.CENTER);
              setContentPane(pane);
              pack();
         public static void main(String[] args) {
              login enter = new login();
    I'm getting the error->The type login must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)
         void is an invalid type for the variable actionPerformed
         Syntax error on token "(", ; expected
         Syntax error, insert ";" to complete LocalVariableDeclarationStatement
    Please help me resolve this error and also to improvise the code.

    You code had basic problem like declaration errors. Have modified your code.
    Try this.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Login extends JFrame implements ActionListener {
        JLabel loginId;
        JTextField Id;
        TextField pwd;
        public Login(){
            setTitle("Login Page");
            //setSize(500,500);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setVisible(true);
            Container pane = getContentPane();
            FlowLayout layout = new FlowLayout();
            pane.setLayout(layout);
            loginId = new JLabel("LoginId : ", JLabel.CENTER);
            Id = new JTextField(20);
            if(Id.equals("shri")) {
                System.out.println("login successful");
            JLabel password = new JLabel("Password : ", JLabel.CENTER);
            pwd = new TextField(20);
            pwd.setEchoChar('*');
            JButton Enter = new JButton("Log in");
            pane.add(loginId);
            pane.add(Id);
            pane.add(password);
            pane.add(pwd);
            pane.add(Enter,BorderLayout.CENTER);
            setContentPane(pane);
            pack();
        public void actionPerformed(ActionEvent e) {
            String read = Id.getText();
            String in = new String(pwd.getText());
            //validate login and password here. validity will be done by sending login/password to the server
            if (read.equals("Shri") && in.equals("Shri")) {
                System.out.println("login successfull");
            } else {
                JOptionPane.showMessageDialog(this,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE);
                Id.setText("");
                pwd.setText("");
                Id.requestFocusInWindow();
        public static void main(String[] args) {
            Login enter = new Login();
    }

  • Font problem when executing a swing program

    Hi! I'm learning to write a simple swing program. The program compiled successfully. When I excuted it, everything worked fine except that I got the following error message:
    Font specified in font.properties not found [--symbol-medium-r-normal--*-%d-*-*-p-*-adobe-fontspecific]
    It's somewhat annoying. Do you have any solution?
    Thank you,
    Liheng

    Thank you. I tried to run Font2DTest. But it didn't work, "Exception in thread "main" java.util.zip.ZipException: No such file or directory"
    I'll keep trying.......
    In JDK under the directory demo/jfc/Font2DTest, there
    is a demo program that shows all available fonts on
    your system. You can find the available font names.
    Then in the font.properties file in jre/lib, search
    for the font name in your error message and replace it
    with an available name from Font2DTest.
    Are you using Unix? What OS, Solaris, Linux?

Maybe you are looking for