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

Thread: Program Runs in Eclipse but Not When Exported

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Location
    Wisconsin
    Posts
    6
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Program Runs in Eclipse but Not When Exported

    I created a program in Java using Eclipse where a Flow Layout containing a text field and an event handler that when a user types in a username and presses enter, the program connects to a mySQL DB and looks for a matching username and selects the rank of that player and a dialog box pops up saying, "<username>'s rank is <rank>"

    Anyway, it runs perfectly in eclipse but when I export (as a runnable Jar) and having the "Package required libraries in generated Jar" selected, the resulting program only goes to the window where a user can input text but when they press enter, (which is where the program connects to a mySQL DB) it does nothing and the typing cursor just flashes.

    I have installed the Connector/J from mySQL into the environment the Eclipse uses, but how do I package it so it goes with the program and my end users don't have to fuss around installing the Connector/J?

    Of course if you have further questions, please ask, but I feel my code is just fine (no warnings when exported) it just wont run outside of Eclipse.


  2. #2
    Member
    Join Date
    Aug 2011
    Posts
    48
    My Mood
    Fine
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: Program Runs in Eclipse but Not When Exported

    In case of error, it should throw an exception. Try to run your jar file from command line:

    java -jar YourJar.jar

    to see if there is any exception message thrown in the console.

    If no, make sure you do not eat the exception, throw it or print stack trace instead.

    immutable objects
    Last edited by ha.minh.nam; December 4th, 2011 at 07:30 PM.

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Location
    Wisconsin
    Posts
    6
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Program Runs in Eclipse but Not When Exported

    I actually solved the problem, Eclipse wasn't packaging the jar with the created jar when I exported the program. All is good now! thanks!

Similar Threads

  1. In eclipse how do you get the runtime of your program?
    By beginnerprogrammer in forum Java Theory & Questions
    Replies: 5
    Last Post: May 22nd, 2011, 03:19 PM
  2. using Eclipse and every program gives the errorr with floating numbers
    By Neera in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 30th, 2010, 12:11 PM
  3. Blackjack program runs excrutiatingly slow.
    By sina12345 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 10th, 2010, 04:55 AM
  4. Thread runs only once and not again
    By enflation in forum Threads
    Replies: 3
    Last Post: June 9th, 2010, 10:51 AM
  5. runs once only
    By silverspoon34 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 21st, 2009, 03:31 AM