i found many related questions here. I have a simple java program . it does not contain a main function. It has a function which takes a string and returns the same . I have made it into a jar file. My question is can i call/ execute this jar file from a shell script. i tested the file in windows using eclipse by creating a new class which has a main function and creating an object of the other class and calling the function. Any help would be appreciated. Pardon me if this is a trivial task.
Share
You can’t execute the jar as an application without there being a
main()routine somewhere; you’ll have to write one and either add it to the jar (this would be easiest!) or create a second jar, or just leave it loose. In any case, one way or another you’ll need to execute the class that contains themain()method.Here are some simple instructions for creating an executable jar file, given that you’ve got that
main()-containing class. Once you have the jar, you can run it usingjava -jar thejar.jar.