Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why jar console program cannot run?

 
Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Intermediate forum...
 
Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 178
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed the problem and thank you for your kind help.
 
sanjay kumar g
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic