1

How create a batch file to a jar file that contains a SortFile.java class that is responsible for sorting the content of a file. This class is taking 2 arguments the first one is sort and the second is file name. I would like to create a batch file that will be moved to cmd and after the path to this batch file user can pass those 2 args. The .jar let's say is on C:\dir\SortFile.jar and I would like to execute this batch from any location. Could someone help me, I never wrote a batch files that executes jars. I google it, but all examples I found did not explain it as well, there was no example for that case I need it.

1 Answer 1

1

Let's go step by step:

The .jar let's say is on C:\dir\SortFile.jar

So your batch file probably should contain java -jar C:\dir\SortFile.jar sort fileToSort (assuming of course that you compiled that Java code already, and that you build the JAR file so that it can be called that way)

I would like to execute this batch from any location.

Then that batch file should be located somewhere in your %PATH%.

If you prefer to use the CLASSPATH, see here for guidance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.