Exposure Java with the JEdit IDE

Exposure Java likes to teach you Java with teeny-tiny files to demonstrate an idea. Most IDE's are designed for when you are making a project with multiple classes that work together. For that reason, Professor Schram likes JCreator LE, which integrates a text editor with 1 button for compiling, and 1 button for executing the bytecode. What if you run Linux, Irix, OSX, Solaris, etc.?

JEdit is a cross-platform open-source program that can be configured so that you can edit the simple one file with the Console Plug-In, you can read my instructions about that here. You can even set up buttons so it works just like JCreator. The down side it that the Console that will execute your byte code does not let you get the System out stream. This means any program (like Java0503.java) that uses the Scanner class will not work in JEdit Console. You have to start up a true Terminal (or Shell or Command Prompt) to run the byte code (you would type "java Java0503" for instance ).

  1. Install the Java SDK if you haven't already.

  2. Download JEdit (currently we're at version 4.2 at the time that I'm writing this) from SourceForge (Pick the right flavor for your operating system: the file will end with ".dmg" for OSX, ".exe" for Windows, ".jar" for generic linux/unix operating systems that have Java installed, and there is a special package available for those of you running a debian machine). If you are using SuSe linux 10.1, you can install jedit right from YaST! (in fact, you better install the JDK 5.0 from YaST as well, to you don't have to manually add the symbolic links and whatever else you need to have these applications work together)

  3. Go ahead and start up JEdit. The first time it start up it shows you the help menu, which is, after all helpful. Go ahead and read what you like, and when you want to move on, close that window.

  4. You should then be looking at something like the screen below. JEdit is a Java applications, like the one's we're writing, so all the menus are in the application's window, rather than the top of the screen.

  5. Now in order for us to use it like JCreator LE in class, we need to install some Plug-Ins, and so make sure you computer is connected to the internet first. Now under the PLUGINS Menu, select Plugin Manager...

  6. You should see this window:

  7. Press the INSTALL button and check Console, then press the INSTALL button on the lower left

  8. If you get an error, don't worry. This just means that the default internet location is not going to work for you. If this is the case, Click the OK button(s) for all the error messages until you are back at the previous dialogue box, and press the DOWNLOAD OPTIONS... button to select a different server.

  9. Press the Update Mirror List button and pick a mirror location near you... you can see below that I chose Arizona. Press the OK button and redo that previous step to try to install the Console Plugin

  10. If that mirror didn't work, pick another. Once you are successful, lets now open Java0301.java from the Progs03 folder that is inside the ChapProgs folder. From the FILE menu, select OPEN...(C+o) (the keyboard short-cut is control-o or Command-o, depending on your platform)

  11. To go up a level, double-click the "/" in the left directory window. To inside a folder or directory, double-click that in the right window. (You can see in the picture below I put the ChapterProgs folder on the Desktop, which for OSX is /Users/<Your-user-name>/Desktop)

  12. To compile our source code into bytecode, (making the file Java0301.class, since the name of our class is "Java0301"), go to PLUGINS menu, select CONSOLE> , then JAVAC (which stands for java compile)

  13. You see this dialog box, which lets you pick things like "optimize", but all you have to do here is press the OK button

  14. It shows you the result, and you can close this window.

  15. Now to see what this program does we select CONSOLE> , then JAVA to instruct java interpreter to call the main method in our bytecode file

  16. Again, you are offered some options, but we can just boldly press the OK button and see

  17. We get our console window which shows in black that our program prints the number 10 (the value of our int a) on one line, then the number 25 (the value of our int b) on another line.

  18. So basicallly, the compile button in JCreator LE in class is done with Plugins>Console>javac and the execute button in JCreator in class is done with Plugins>Console>java. We can add buttons on the tool bar so it looks more like JCreator

    You can see in picture above is how I configured my JEdit to look more like JCreator. From the Utilities Menu select Global Options

    Most of this is to mimic JCreator... feel free to configure your IDE any way you like!