Can i Run Java file from Shell?

i have some code in java, it takes an input as args, then process and prints output, any way to get that to ob2? shell command may work but i can’'t figure out how to use