Here is an online Java IDE -- an editor that also lets you
run code right in the browser. At the top is the editor, below that is a Run button, and then below that the output.
You can edit the code in the editor and run it as many times as you want. This does unfortunately have ads,
some of which might be misleading; you do not need to download any extra tools to use this page, just save your file.
You may also use any other java IDE you prefer, this is the most convenient one I found.
About the Java IDE:
- At top left there is a save (floppy) button which lets you download a copy of the file.
Save often and don't lose your work! It WILL NOT SAVE your code if you close the browser, so you need to download your work!!!
- You have to click Run again each time you want it to run your code to test changes.
- As you type, the editor tries to help by providing suggestions, but these pull from all of Java instead of
just from the tools we are using, so its suggestions may not be useful! You can turn this off using the settings (gears) button
at top right and unchecking Autocomplete at the bottom of the list, if it annoys you.
- If your output has the word error in it, java is telling you that you have a syntax error you need to fix.
It will try to tell you the line number, but sometimes an error in an earlier line can cause a problem that
doesn't show up til a later line.
Using the IDE
- The editor page starts off with example code in it. At the top of the editor is a + button. Click this to create a
new file and change the name so the name of the file is the same as as the name of the class with .java at the end.
For instance, if the name of the class is MainA, the file should be MainA.java
- You can paste my example code into a blank .java file you created in the editor and then start editing it. You can also use the open button to open an existing .java file from your computer.