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 12 of 12

Thread: Hi everybody! But there is a problem...

  1. #1
    Junior Member NightmareX2000's Avatar
    Join Date
    Sep 2012
    Location
    Somewhere in Nevada
    Posts
    6
    My Mood
    Inspired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Hi everybody! But there is a problem...

    Hi!

    I am using NetBeans IDE 7.2 and trying to find out why my java-GUI application doesn't work when double clicked but works normaly when I start it from NetBeans .

    When I start my GUI app with doble clicking it, looks like started but no windows seen.
    However it's working well when program started in NetBeans...

    Thanks in advance!..
    {Sorry for my mistakes}

    [JAVA][/JAVA]


  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: Hi everybody! But there is a problem...

    Perhaps you have resources such as images or files that are not available in your jar file. It's hard to say without code.

  3. #3
    Junior Member NightmareX2000's Avatar
    Join Date
    Sep 2012
    Location
    Somewhere in Nevada
    Posts
    6
    My Mood
    Inspired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Hi everybody! But there is a problem...

    I have a realy simple java-gui application with no resource file or something. The problem is when I try to open my application with my ways, almost nothing happens - except mouse changement - but my app starts normaly when opened with NetBeans (pressing the Run button or F6)
    Shortly; opens normal with NetBeans, nothing happens with command line or double-click.

    Thanks in advance!..
    {Sorry for my mistakes}
    Last edited by NightmareX2000; September 3rd, 2012 at 02:35 PM.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Hi everybody! But there is a problem...

    How are you trying to execute the program?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member NightmareX2000's Avatar
    Join Date
    Sep 2012
    Location
    Somewhere in Nevada
    Posts
    6
    My Mood
    Inspired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Hi everybody! But there is a problem...

    IcoJava.jpg
    I'm just clicking on it but no windows or something appears

  6. #6
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Hi everybody! But there is a problem...

    You either have an error or you're target program to open the file isn't linking to the Java in the JRE directory.
    Open command prompt in the directory of your file, and enter java -jar JavaApplication2.jar.

    If it opens with no error messages, it's because you haven't set the right target for .jars, but if you have errors, paste them in here.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Hi everybody! But there is a problem...

    On windows: To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member NightmareX2000's Avatar
    Join Date
    Sep 2012
    Location
    Somewhere in Nevada
    Posts
    6
    My Mood
    Inspired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Hi everybody! But there is a problem...

    Error: Could not find or load main class javaapplication2.JavaApplication2

    I tried to do the same thing in javaFX and it has no problem at all. I copied codes to a javaFX project and it works fine when double clicked.

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Hi everybody! But there is a problem...

    Look in the jar file with a zip utility:
    1)Read the manifest file. What is in it?

    2)Is there a class file named: JavaApplication2 in the javaapplication2 folder?
    Last edited by Norm; September 3rd, 2012 at 03:18 PM.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member NightmareX2000's Avatar
    Join Date
    Sep 2012
    Location
    Somewhere in Nevada
    Posts
    6
    My Mood
    Inspired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Hi everybody! But there is a problem...

    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.8.3
    Created-By: 1.7.0_07-b10 (Oracle Corporation)
    Class-Path:
    X-COMMENT: Main-Class will be added automatically by build
    Main-Class: javaapplication2.JavaApplication2

    There is 2 class files which named NewJFrame and NewJFrame$1 . But I was already selected the main class in NetBeans.

    Maybe its the problem...

  11. #11
    Junior Member NightmareX2000's Avatar
    Join Date
    Sep 2012
    Location
    Somewhere in Nevada
    Posts
    6
    My Mood
    Inspired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Hi everybody! But there is a problem...

    Thanks in advance!..


  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Hi everybody! But there is a problem...

    This line tells the java program where to start:
    Main-Class: javaapplication2.JavaApplication2

    it's going to look for that class file in the jar file.

    If that class file is NOT in the jar file, you get the error:
    Could not find or load main class javaapplication2.JavaApplication2

    You need to find out how to use the IDE to build a jar file. There is a section of the forum for problems with IDEs.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 3
    Last Post: January 5th, 2012, 01:44 AM