I'm looking for a quick way to run multiple blocks of Java code from Stack Overflow one code block at a time. Many Java questions at Stack Overflow have multiple answers, and I want to test most or all of the answers to a given question with my own data to determine if the code works or not. For the purpose of answering this question the Java code block doesn't need to be executable as is, because I can edit the code and add the first line(s) of code and their closing bracket(s) and the data so that the code block runs and gives output. Console output would be enough.

  • I don't want to have to create a project each time I run a new block of Java code. I want to copy/paste a code block and run it without making a project of any kind. The reason for this is I expect to reject most of the code blocks that I try, and I don't want to clutter my system with a lot of useless projects. That rules out some Java IDEs that I know about.

  • I'm not looking for an online application.


2 Answers 2


JShell — a REPL now bundled with Java

You may find useful the REPL tool now bundled with Java 9 and later, JShell, defined in JEP 222.

Use a search-engine to find many demonstrations, both written and video.


I usally have an empty project in a folder and if i have to test sth really quick i open up the empty project.

Maybe you could try visual studio code with a java plugin. It opens up pretty fast and you can just run .java files.

  • I don't want to make a project. I want to run the code directly from a single file inside the application. When I'm finished running the code I want to either delete that file or save it.
    – karel
    Commented Jul 29, 2019 at 14:36
  • you can do this with visual studio code. Click new file, paste the code into the file, save the file as java file, run the code. If the code sucked test the next one. Save the file e.g to your desktop so you can delete it easy later Commented Jul 29, 2019 at 14:37
  • That's what I want to do. I want to save the file to my desktop so I know where it is and I can delete it as soon as I'm finished with it. That way I can easily see whatever files that I'm working on, and if I'm interrupted then I can see where my files are the next time I login.
    – karel
    Commented Jul 29, 2019 at 14:39
  • Is your problem now solved? Commented Jul 29, 2019 at 14:41
  • That's the way I want to save the files, but I asked how to quickly run them from inside the application and maybe do a little bit of basic debugging because I'm sometimes starting with just a code snippet and I need to edit the code snippet and add a few lines of code so that I can run it.
    – karel
    Commented Jul 29, 2019 at 14:43

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.