Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: JAR Run Perfect in My Ubuntu 12.04 but not in Windows or Another OS

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default JAR Run Perfect in My Ubuntu 12.04 but not in Windows or Another OS

    Hello, this is my first post. I have created an application with Java SWING using Netbeans 7.1.2. in Ubuntu 12.04. Actually all finished, and i can run my JAR of my application perfectly in my Ubuntu 12.04 machine (ASUS X44C). The problem comes when:

    1) My friend runs that JAR in his Windows 7 in laptop.
    2) My another friend runs that in his Ubuntu 12.04 laptop (not mine).

    The problem:

    Button in my app, should open another frame when clicked. In my Ubuntu, i have tested it and perfectly runs. All buttons work. But in another system, with same JAR file, the buttons made my app disposed only (not open the new frame requested). But the strange, only one another button works there. That button has similiar code with the didn't work one.

    Diagnosys:

    I don't know why but my code for the button didn't work is:

    private void btPemulaActionPerformed(java.awt.event.ActionEvent evt) {                                         
            if(btPemula.isEnabled()==true){
            this.dispose();
            new JendelaOtodidak().setVisible(true);
            }
    }

    The button codes that work is:

    private void btTentangActionPerformed(java.awt.event.ActionEvent evt) {                                          
            if(btTentang.isEnabled()==true){
            new TentangOtodidak().setVisible(true);}
        }
    }

    and the only difference between them is this.dispose() code. Maybe it is the problem (I don't know because I made it only by Matisse).

    My question:

    What's wrong? What should I do so my JAR can run perfectly in Linux and Windows? Thank you. I am sorry I'm newbie.



  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: JAR Run Perfect in My Ubuntu 12.04 but not in Windows or Another OS

    Dispose will usually do what you tell it to do by calling the setDefaultCloseOperation(...) on your JFrame with proper parameter, which I think for you will be (JFrame.DISPOSE_ON_CLOSE.

    Regardless -- it's generally not a good program design to fling multiple windows at your user. Better to swap the *views* on a single window using a CardLayout. If your main window must show sub windows, use a dialog such as a JDialog or JOptionPane.

  3. The Following User Says Thank You to curmudgeon For This Useful Post:

    Malsasa (February 3rd, 2013)

  4. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: JAR Run Perfect in My Ubuntu 12.04 but not in Windows or Another OS

    Oooh, so I should use single window? Yes, actually I want to do that because I wanna make my application is like Windows Application Installer, we can click next-next-finish. I think such application can be created with many frames, so I do that. Now my app has more than 30+ frames, all JFrame. I don't know exactly how to make just single frame then the contents can be changed dinamically (it seems like Ubiquity Linux Installer). If I know, I will do that.

    Any suggestion or links? But thank you so much for kind reply

    --- Update ---

    My tester have captured my app in Linux Mint 14 Nadia and get this error message:



    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/netbeans/lib/awtextra/AbsoluteLayout


    --- Update ---

    Complete error messages he'd pasted here: pesan kesalahan - Pastebin.com

  5. #4
    Junior Member
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: JAR Run Perfect in My Ubuntu 12.04 but not in Windows or Another OS

    SOLVED! Thank you.

    The only one problem is AbsoluteLayout.jar is not included within my app's JAR. The solution is (via Netbeans):

    1) Create new package named org.netbeans.lib.awtextra within project.
    2) Just copy-paste AbsoluteLayout.class and AbsoluteConstraints.class from org.netbeans.lib.awtextra in the bottom of it to that package. Look at your left side of Netbeans.
    3) Build and Clean again.
    4) Done, perfectly.

    You can see the screenshot here:

    M9JGdKp.jpg

    And my conclusion is we need to add new package of AbsoluteLayout within our project if our project has used AbsluteLayout. Alhamdulillah, all praises to Allah. All done. Thank you

    Reference: https://forums.oracle.com/forums/thr...sageID=5528267 (really solves my problem!)

Similar Threads

  1. i want run app as windows service.
    By skuskusas in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 5th, 2012, 04:03 AM
  2. Run a jar file inside a batch file with Windows 7 Task schduler
    By kingnachi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 15th, 2012, 09:20 AM
  3. Problem running .jar in Windows 7
    By SpiceProgrammer in forum Java Theory & Questions
    Replies: 3
    Last Post: December 21st, 2011, 01:28 AM
  4. Replies: 2
    Last Post: July 12th, 2011, 06:24 AM
  5. My Jar File Crashing Windows 7
    By PrinceSendai in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 19th, 2011, 02:49 PM