I have written a code which uses RXTX Serial API for communication. Now I want to distribute a jar file for my program. The problem is that since I have used RXTX Serial API jar & dll files for this needs to be copied in java home. I wrote a code to copy this files in a correct location. Now after running the copy code if I rum my main program code it runs fine. But if I don't run my copy code first the other main program doesn't run. Fair and square. Now Since I have to distribute my code single jar file I can't ask user to run two different programs. I have to do it with one jar only. So I wrote a third program which calls my first code methods to copy the file and then my main code methods. This program is able to copy the files correctly but when it tries to run my Main program it fails saying that Serial API files are missing. And if I again try to run my program it runs perfectly. That proves the code checks for the resources before running only and any resource added during runtime doesn't count. So what I was thinking is it possible to run two java programs from one jar file one after the another like we can do with batch files?

Recommended Answers

All 2 Replies

That proves the code checks for the resources before running only and any resource added during runtime doesn't count. So what I was thinking is it possible to run two java programs from one jar file one after the another like we can do with batch files?

What kind of resources are we talking about here? What is the exact exception message?

is it possible to run two java programs from one jar file one after the another like we can do with batch files?

Yes by using a commandline with the starting class named:
java -cp THEJARFILE.jar Class1
java -cp THEJARFILE.jar Class2

The -jar option reads the Main-Class: line of the manifest to get the name of the starting class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.