Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopherjanzen/529c9bf307cc5d38b4eff1c72f3e5b30 to your computer and use it in GitHub Desktop.
Save christopherjanzen/529c9bf307cc5d38b4eff1c72f3e5b30 to your computer and use it in GitHub Desktop.
Configuring Java and Atom on Mac and Windows for easy development

Configuring Java and Atom on Mac and Windows for easy development

Setting up on Mac OS environment

Downloading and installing Java JDK

First things first we need to download and install the latest Java JDK onto our system which you can find here.

Once this has been installed we need to tell the OS to use this latest version of Java instead of the preinstalled one that came with the system.

To do this we are going to open up terminal or your command line interface of choice. I am assuming you are using the bash shell (if you don't know what this means you probably are).

export JAVA_HOME=`/usr/libexec/java_home -v currentVersion eg. 1.8`

export PATH=$"JAVA_HOME /bin:$PATH"

Nothing will have appeared to happen but if you type java -version the correct Java version should be displayed.

The hard part is over!

Downloading and installing Atom

Head over to atom.io to download and install the Atom text editor.

This is where you will be spending most of your time. This is a text editor that can be extended with plugins to make our lives easier. We're going to be installing a few plugins to make Java development a heck of a lot easier for ourselves.

Once you have Atom installed we're going to be installing atom-ide-ui, ide-java, and script.

The easiest way to install these plugins (or packages as Atom calls them) is to go to Atom>Preferences...>Install and then search for each package to install them.

If everything went according to plan you should now be able to compile your Java files from within Atom by using the shortcut cmd i.

For example, if I wrote a HelloWorld.java file I would open it in Atom and then use my shortcut. I should get a compiled class file and if there were any println statements they should appear in the bottom of the Atom window. Make sure that you do not have any text selected in your file when running the Script package as it will not compile if you do.

Setting up on Windows environment

Downloading and installing Java JDK

First things first we need to download and install the latest Java JDK onto our system which you can find here.

Once this has been installed we need to tell the OS to use this latest version of Java instead of the preinstalled one that came with the system.

The Java JDK should have been installed at C:\Program Files\Java\jdk-10.0.* with the * being the specific patch version (At the time of writing 10.0.1).

To set the OS to use our newest version of the JDK we'll go to Control Panel>System and Security (or just System)>Advanced System Settings. Then in the new window we'll go to Advanced>Environment Variables.

We're going to be making changes to the System Variables. Find Path and then choose Edit.... In the new window that opens click on New and type in the JDK bin directory which is your install directory followed by \bin. For example: C:\Program Files\Java\jdk-10.0.1\bin. Click on Move Up and make sure this entry is at the top of the list.

You should now have the Java JDK properly installed on your system but to verify you can open Command Promt and type java -version to see which version of the JDK is being used. You should also be able to type javac -version to see that the Java compiler is installed properly as well.

Downloading and installing Atom

Head over to atom.io to download and install the Atom text editor.

This is where you will be spending most of your time. This is a text editor that can be extended with plugins to make our lives easier. We're going to be installing a few plugins to make Java development a heck of a lot easier for ourselves.

Once you have Atom installed we're going to be installing atom-ide-ui, ide-java, and script.

The easiest way to install these plugins (or packages as Atom calls them) is to go to File>Settings...>Install and then search for each package to install them.

We may need to make a tweak to the ide-java package so go to File>Settings>Packages and click on the ide-java package. From here you should see a Java Home text box where we'll type in the location of our JDK we saw from earlier. For example: C:\Program Files\Java\jdk-10.0.1.

If everything went according to plan you should now be able to compile your Java files from within Atom by using the shortcut shift ctrl b.

For example, if I wrote a HelloWorld.java file I would open it in Atom and then use my shortcut. I should get a compiled class file and if there were any println statements they should appear in the bottom of the Atom window. Make sure that you do not have any text selected in your file when running the Script package as it will not compile if you do.

A few extras

I'd highly encourage you to check out some other Atom packages and themes as they can make your life a lot easier. Be careful though as it's easy to get sucked into forever setting up new packages and themes and never getting any actual work done!

You can also compile java from the command line by directly using javac. As long as you are in the directory with your .java file you can run:

javac HelloWorld.java

to get a compiled HelloWorld.class file.

You can then run it from the command line by typing:

java HelloWorld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment