1

I'm writing a script to validate I/O for contest problem solutions under a given directory for any of the following language types:

  • binary files (c, c++, etc.)
  • java classes
  • scripts (ruby, python, etc.)

I noticed the only one of the three above listed types that cannot be executed in a unix-style syntax ./program < sometest.in is Java. Obviously it's not difficult to simply check file extension in the script and replace above command with format java program < sometest.in, but it made me curious:

Is there a way to use unix-style syntax to run a Java class?

1 Answer 1

2

You would need to wrap your Java class / JAR file into a little shell script:

#!/bin/sh

read input
java -jar program.jar $input

Make the file executable:

chmod a+x program

Use it as suggested in your question:

./program < sometest.in
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.