Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

running java file under jar

 
arjun rampal
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have a jar file which function like this

It Takes the data file from the folder and insert it into database now again next day it takes the data file(new one)
and delete old data and insert new data.
There is file handle.java which is need to be invoked to do all these functions

Now question-
1)only deploying jar file on server will work?

2)if yes How to invoke this file under jar usind java command? command because it is linux

Regards
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you will probably need to set a classpath, which should at least include your jar file and probably another jar that has the database driver. It's possible that other entries will also be needed.

Once you get the classpath right, you should be able to invoke the class the same way you would if it were in a directory:

java handle

I assume handle.java (should be Handle.java, but I won't quibble) has a main method? Alternately, you can get fancy with the jar's manifest. This would allow you to invoke it as:

java -jar yourjar.jar

The Java command line tools work the same on Windows and Linux.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic