Sublime Forum

How to use Sublime REPL for Java



I started programming Java with Sublime text 3.
I was looking for a suitable solution to my problem everywhere, but i did not find.
How can I give an input in Sublimetext 3?
I configured It to run my programm in Sublimetext but i dont know how to organize it to give an input.
I saw a video how they do it with the REPL addon for Python but it seems it doesn’t supports the Java language.





Thanks for your quick answer!
I still have some Problems to use Sublime as my Java IDE.
Can you please help me to make a build system that run my Java program and put out Hello World for example?
it shows [Finished in 0.71s] only.

What are the steps I need to do that it puts out Hello World and how i can give an Input to the programm i showed your Video but for me it doesn’t work for Java.
Sorry for this questions but im a noob and i need some help to start with Java :slight_smile:



The build system for Java that comes with Sublime only compiles code and doesn’t run it, so if you used that one, that would be the issue. For something like Java you ideally want to use a dedicated build tool like ant or maven or such. Sublime has a build system for ant already so if you used that one, you’d be mostly good to go.

The following post includes a version of the built in java build that compiles and then runs the code, though it will only work for a single file Java program:



I tried this code for my build system but it doesn’t work,
if i try to run it with i have this error.



Is the Java file that you’re trying to run in the E:\patrick\Java folder directly (not say a sub-folder or such)?

The build system as outlined in that post sets the working_dir field to "${project_path:${folder}}"; working_dir is analagous to what folder your terminal would be sitting in when you manually enter the text in shell_cmd to run the build.

The shell_cmd just passes the name of the current file to the javac command, so the assumption is that the file you’re running can be found in the current directory, and if not things will go all errory on you.

The definition for the working_dir sets the current directory to:

  1. The folder that contains your sublime-project file
  2. The first folder open in the sidebar if you’re not using a sublime-project file
  3. Nothing at all if you’re not using a project and have no folders open

Depending on where you keep your Java files, an adjustment to the build may be in order.



Thanks very much i see the problem, but i dont know how to organize my build correctly and what i have to code that i can run my programms directly in Sublimetext and maybe to give an input to my programm for example (the program ask your name and then u have to type name in and the program tells hello (name) to you)?

I saved my files as follows: files

I showed your video about terminus and i tried to do it correctly that i can give an input to my program but i destroyed my build system lol.

I very want do youse Sublime as my IDE for Java



For just a single file Java program I would use the build from the post above, but with this in place of the existing similar line:

"working_dir": "$file_path",

That makes the command run in the same directory as the file you’re trying to compile. if you then also add in the two lines for using Terminus, you should be good to go.