File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Why jar console program cannot run? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why jar console program cannot run? " Watch "Why jar console program cannot run? " New topic
Author

Why jar console program cannot run?

Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Hi,

I built a console application on windows. It works fine when I run it on JBuilder. It has a timer to run the Socket Connection with another server and exchange data for every minute.

I built the archives - both native executable jar file and console exe file.

I run it in console window. It can display the first print line of the program: "Starting Data Exchange ..."

However, I did not see the data updating in both servers.

The console program seems running from connecting to local DB till printing out Starting Data Exchange ...

I am not sure whether the code insides the timertask has run or not. It is ok when I run it in JBuilder.

So, is it the timer bug or the classpath issue?

What may be the deployment problems?

Thanks for any kind advice.

Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Andrew, you've posted a most incomplete code example. Also, I'm thinking that this might be a bit beyond the beginner level we aim for in this forum.

So, how about some more complete code and then we figure out a better forum for this conversation?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Yes, it is complete code in main method. except

main.DBConnection();
main.dataexchange();

I added println in the above 2 methods to check whether they are executed and I did not see the println. Do you think it is the timer issue?

If I placed in the wrong forum, can you help me move to the proper level?

Thanks for help.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
There's more than those two things missing from your posted code. Did you even try it?

At any rate, perhaps the following excerpt from the Timer class documentation helps to shed some light on your troubles.
After the last live reference to a Timer object goes away and all outstanding tasks have completed execution, the timer's task execution thread terminates gracefully (and becomes subject to garbage collection).
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
See what the following code does, if you don't close that JOptionPane, and just let it sit there for some time more than 60 seconds.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Intermediate forum...
Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Hi,

I modified the code and found where is the bug. When I run the jar program in console window.

The pop up ConfirmDialog box displayed and the console window printed:

Starting Data Exchange ...

New an instance. //able to new an instance

Prepare to connect DB. //able to call the DBConnection method.

Prepare to get connection pool. //prepare get connection with the pool

It does NOT show "Got connection pool." and print the following error:

java.lang.NullPointerException

java.util.Timer@141b571

I used MSSQL 2000 JDBC driver and it does not has problem when I run the program in JBuilder.

Did it lose the DataEx main object or it is the thread problem? What are the potential problems and how can I debug it?

Thanks for any kind advice.

Here is the updated code:



:roll:
Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
I fixed the problem and thank you for your kind help.
sanjay kumar g
Greenhorn

Joined: Sep 16, 2013
Posts: 1
Andrew Parker wrote:I fixed the problem and thank you for your kind help.




Hi Can you please let me know how did you fix this problem, because I am also getting same problem, you answer would be much apriciated

thanks,
Sanjay
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
sanjay kumar g wrote:Hi Can you please let me know how did you fix this problem, because I am also getting same problem, you answer would be much apriciated

Andrew's last post on these forums was 9 years ago, so I wouldn't hold out too much hope of a reply.
You're probably better off starting a new thread which describes your exact problem. Don't forget to TellTheDetails.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39380
    
  28
Welcome to the Ranch Stuart is correct. You would need to describe exactly what is happening, and I may move your post to a new topic.
 
 
subject: Why jar console program cannot run?