0

Essentially the question boils down to 'Is there a way to run a class/jar file using the console for input/output without having JDK'. I've written a program in Java for a colleague to use in his work, but he doesn't have/use JDK. I'm aware there are online compilers, but at this point my question has become focused on running a program directly for interest reasons.

Essentially the program is designed to output instructions to the user, the user makes input in accordance with the instructions, and this goes back and forth for awhile before the program does some calculations based off the input and returns a final result.

I should mention that he has JRE.

My program doesn't use a GUI, it just prints instructions to the console and gathers input from responses typed in the console. It works fine on my computer when running it from the command line ('java myprogram'), but without jdk the java command isn't available to him, which seems to mean he can't run a class file.

My next attempt was to turn the program into an executable jar file, but using the command 'myprogram.jar' from the command line doesn't really do anything. The jar file does include a manifest. I added a blank screen to the code and running the jar file did create the screen, but still no i/o on the console. From what I've read, I think this is because jar files aren't automatically associated with a console, so there is nowhere for the program's output to go or input to come from. He can't use the 'java -jar myprogram.jar' command because he hasn't got the JDK, so even though that command runs the program the way I want it to, it's not an option.

Basically, I'm wondering if it's possible for someone without JDK to run a program and interact with it entirely using the console/command line and no other interface?

  • 3
    *"I should mention that he has JRE"* then they have Java and run compiled code, they just can't compile source code. It's more likely that they don't have Java available in the OS's "search path" – MadProgrammer Jun 13 '18 at 22:56
  • For Java 9 and later: [*jlink: The Java Linker*](http://openjdk.java.net/jeps/282) and [*Modular Run-Time Images*](http://openjdk.java.net/jeps/220). – Basil Bourque Jun 13 '18 at 23:31
  • @MadProgrammer Thank you, that was the problem. My colleague also says thank you. Out of curiosity, do you know if there have been a solution that didn't involve adjusting the path? – guest4419 Jun 15 '18 at 04:06
  • @guest4419 "Better" is subjective. We've "embedded" the JRE we wanted out clients to use with our App (as part of the installation process), then we had a executable command setup to directly use it – MadProgrammer Jun 15 '18 at 04:14

0 Answers0