aspose file tools*
The moose likes Java in General and the fly likes running java file under jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "running java file under jar" Watch "running java file under jar" New topic
Author

running java file under jar

arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
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

Joined: Oct 01, 2001
Posts: 2861
    
  11

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: running java file under jar