How to run java programs in Atom editor


Bare with me
I go to Packages - Script - Run Script (or Ctrl+Shft+B) and get this

I have already selected Java as the language.

How do I configure this

into the script or am I suppost to add the Java language to the atom-runner?



That’s nothing to do with either of the packages. If you go to your System settings and click on Advanced System Settings, it brings up a window with a button that says Environment Variables at the bottom. You can click on that and then there are two Path variables, one for the user in the top window and one for the whole system in the bottom. Look in both of them for something that looks like it points to the JDK on your computer. If that’s not present, that might be the cause your error.

or am I suppost to add the Java language to the atom-runner?

Is that what the Runner documentation says to do? I think you’re getting ahead of yourself, trying to get two different packages to work at the same time, and you aren’t differentiating between them in your questions. Focus on Script for now.



Java isn’t designed to be executed in a selection-based or line-by-line way like scripting languages are. I’m not surprised that there is no support for executing Java in this manner. I doubt there is a way around this error.



As for the Environment Variables this is what it looks like

If it is too much trouble to run Java in the Atom editor I can always just use Netbeans. I just don’t understand what I am doing wrong where it goes to the point where I can not use an entire language in Atom. Has anyone else found success in being able to run Java programs in Atom?

I also tried to run ruby and I receive this error “‘ruby’ is not recognized as an internal or external command,
operable program or batch file.”

My environment variables for Ruby look like this



You can’t use any language in Atom except for HTML, CSS, Less, or JavaScript/CoffeeScript. Packages like Script and Runner mediate with external tools. If the Script documentation is not sufficient to successfully execute Java, then you should bring up the issue with the package authors.

As for the Environment Variables this is what it looks like

You have not yet demonstrated that you have followed the instructions in the Script docs. You need to actually open up the Path environment variable so that we can see the individual directories it points to. If there’s not a ...\jdk1.x.x_xx\bin\ somewhere in there, then you need to add it (with the version number of your instance of JDK, of course).

I also tried to run ruby and I receive this error “‘ruby’ is not recognized as an internal or external command, operable program or batch file.”

Because the Ruby executable is not in your Path. What’s in the C:\Ruby23-x64 directory?

1 Like


Java isn’t a scripting language like Ruby, Python or Perl. Java is intended to be a compiled language where you build an entire program and execute it as a comprehensive whole. Atom supports Java as much as it supports any other language, it allows you to edit the code. Executing the code is outside the scope of what Atom provides. For more information, see the Atom FAQ:

If you need support for Java, what it is intended for and how to make it work, Oracle’s documentation or Stack Overflow would probably be better resources.



I fixed my Ruby issue.

After installing the latest version of Ruby

I installed Rapid Environment Editor to edit the paths for me.

After installing the editor I had to restart it as administrator.

Next, right click your path

Add value > Insert Directory Path > select the Ruby bin

Open your command prompt and type ruby.
If the same error that you received in atom does not occur in the command prompt than cheers!



As for the Java path.



In that case, you’ve satisfied what the docs ask you to do and you should bring that up as an issue with the maintainers of the package.



I’ve succesfully built .java files by using the Package - Script on Mac OS X and doing a Command-i to build the java file and execute. This brings up a command execution in the lower pane and shows the output of the run.



You need to have a full class code if you want to run Java. Java cannot be ran if it’s not embedded in a class structure. Interpreted languages like python can be, but not Java. so a hello world in Java looks like this:

class HelloWorld {
     public static void main(String[] args){
        System.out.println("Hello World");

Keep in mind that the filename must be the same as the class name. In this case :



Java can be hacked to be executed line by line:

However, it’s not pleasant, and I wouldn’t recommend it. If you really like java and also really want an interpreted language, Scala is pretty close, and comes with a repl by default.

All that said, atom is an editor. Java, by design, nearly requires the use of an IDE to code effectively. It has very strict formatting requirements, a lot of ways to do the same thing, and a tendency toward longer variable/class names, lines of code, and files (verbosity).

I use atom at work to write ruby and python, and intellij for java. If you really want to run java programs in atom, why not try one of the terminal programs? works pretty well, and you can javac and java there just like you could regularly on the command line.

1 Like


what should I do? I have installed java 1.8 version :disappointed_relieved::cry:


How to code in java?

The script package worked successfully and the response indicates that the error is with your Java installation, so you may have to reinstall it (or try installing 1.7).

1 Like


ok :+1::+1: thanks



should I download Java SE Development Kit or is there any other , I am totally new so i don’t know



now I am getting this error what to do ? @DamnedScholar



Please share your entire Atom window, not just the script pane. I can tell you more if I see the code file and your file tree.



I don’t need to know what program you’re trying to run, I just need to see your code file and file tree and I can probably tell you why the file isn’t getting run. Specifically, if there’s a space anywhere in the path of your file, that will cause script to fail. It’s an old package with some bugs, and it’s likely that your issues are caused by the package itself. I personally use process-palette, which demands a little more knowledge of the command line, but gives you the most flexibility and control.



sorry, where do i find code file and tree file ? I am totally a newbie