Results 1 to 7 of 7
  1. #1
    DrBagelBites is offline Member
    Join Date
    Sep 2014
    Posts
    4
    Rep Power
    0

    Default Code compiles and runs, but window does not pop up.

    To give some background, I am using Ubuntu 14.04, and am compiling my code via the terminal.

    The problem is not in the compiling and running of the program, but the window in for the program does not show.
    The icon with the penguin shows up as if there is a window to be opened, but there isn't one.
    I have tried uninstalling all of my java components on my computer and reinstalling, but it did not work. I realize it must be something with my java setup, but I am at a loss of what it could be.

    The computer is able to print program output to command line as it should, but windows are not working.
    Here is the code that I am trying to run. Any help would be much much appreciated!

    Thanks in advance.

    Java Code:
    public class HelloJava1 extends javax.swing.JComponent
    {
        public static void main(String[] args)
        {
            javax.swing.JFrame f = new javax.swing.JFrame("HelloJava1");
            f.setSize(300, 300);
            f.getContentPane().add(new HelloJava1());
            f.setVisible(true);
        }   
    
        public void paintComponent(java.awt.Graphics g)
        {
            g.drawString("Hello, Java!", 125, 95);
        }
    }

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Code compiles and runs, but window does not pop up.

    It works on my Win7 PC.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    DrBagelBites is offline Member
    Join Date
    Sep 2014
    Posts
    4
    Rep Power
    0

    Default Re: Code compiles and runs, but window does not pop up.

    Code compiles and runs, but window does not pop up.-javaproblem.png
    Quote Originally Posted by Norm View Post
    It works on my Win7 PC.
    Yeah, I know the code works. I am asking if anyone would have any insight as to why it isn't working on my computer.

    edit: I added a picture that way you can see what I am seeing. I use javac and java, then the icon appears, but no window.
    Last edited by DrBagelBites; 09-25-2014 at 09:26 PM.

  4. #4
    MGeorge's Avatar
    MGeorge is offline Aging Hacker
    Join Date
    Sep 2014
    Location
    East (San Francisco) Bay, California, USA
    Posts
    20
    Rep Power
    0

    Default Re: Code compiles and runs, but window does not pop up.

    What is the DISPLAY environment variable set to in the window you use to run the program?
    Your window may be popping up on somebody else's monitor.

  5. #5
    DrBagelBites is offline Member
    Join Date
    Sep 2014
    Posts
    4
    Rep Power
    0

    Default Re: Code compiles and runs, but window does not pop up.

    So, I did echo $DISPLAY, and it came back as :0.

    edit: I do have two monitors by the way. Running the same command on the other monitor yields the same result.
    Last edited by DrBagelBites; 09-27-2014 at 03:11 AM.

  6. #6
    DrBagelBites is offline Member
    Join Date
    Sep 2014
    Posts
    4
    Rep Power
    0

    Default Re: Code compiles and runs, but window does not pop up.

    Update: I have tried testing the code with one of my monitors unplugged and it works perfectly. So, there must be something about having two monitors that is screwing up my code.

    Update2: I have found that the window is off screen. Once I restart the application it starts off screen again.
    Last edited by DrBagelBites; 09-27-2014 at 04:34 AM.

  7. #7
    MGeorge's Avatar
    MGeorge is offline Aging Hacker
    Join Date
    Sep 2014
    Location
    East (San Francisco) Bay, California, USA
    Posts
    20
    Rep Power
    0

    Default Re: Code compiles and runs, but window does not pop up.

    I have never worked on a multi-headed system so I may not be the best qualified person to help. That said, I'm accustomed to seeing DISPLAY set to something like <your-host-name-here>:0.0. You might try that syntax and see what happens. That's my best guess.

Similar Threads

  1. Replies: 1
    Last Post: 09-19-2011, 01:53 PM
  2. Compiles and runs but won't recognize password
    By fable13 in forum New To Java
    Replies: 3
    Last Post: 07-04-2011, 10:23 PM
  3. Help Creating a GUI applet window that compiles my program
    By ReclaimerGold in forum New To Java
    Replies: 3
    Last Post: 04-29-2011, 12:27 AM
  4. Replies: 6
    Last Post: 02-08-2011, 02:29 AM
  5. Code compiles in/runs in IDE but not on UNIX system
    By Unclejunebug in forum New To Java
    Replies: 7
    Last Post: 10-08-2009, 08:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •