Pages Menu
Categories Menu

Posted by on Jan 9, 2016 in Featured, Google Apps, Programming, Software |

Online Java Programming

Online Java Programming

So the year is 2016.  Elementary and middle school students are learning to code online.  My junior-level Introduction to Programming course students are learning to code online.  What about my senior AP Computer Science students?  Nope.  Well, not until now.  However, its not simple.

I cannot believe in 2016 I cannot find a better plan or workflow with which my AP CS A students can program online.  Either I’m missing something (its possible), or the web just isn’t suited (as of this writing) for decent introductory programming of Java online.  Don’t get me wrong, there are some tools out there (of which I’ll review some), but in my opinion they are clearly lacking.  Either the tools are far too simplistic/rudimentary or they are far too complex.  There’s got to be a happy medium.  Such was my quest.

There are a few aspects of programming in Java that must be taken into account when dealing with students.  First, they need a text editor.  A nice text editor is really not difficult to find, there are tons of options.  Even if you don’t have a nice one, you always have the free basic editors that come with your OS (e.g. Notepad, TextEdit).  Second, you need a compiler.  If you’re working in a Mac environment, you have an advantage, its already installed.  If you’re on Windows, it must be downloaded (easy), installed (easy), and then typically be setup to work with your machine’s PATH variable (intermediate) if you’re going to use a command-prompt (which is what I do initially).  You can possibly avoid this last installation issue if you install an nice IDE for your students to use (e.g. JCreator, Eclipse, NetBeans).

Once you have your text editor and compiler, you are really all set to program on your local computer.  But, what if you want to work on another computer.  In the past we transferred our programs from one computer to another in a variety of ways, but today you use the cloud (hopefully).  Transferring is not the hard part, you now need to find another machine setup to work with Java.  For my students this often means them trying to download and install Java the same way I did in our lab.  Of course I provide them with instructions, but, well, you know, that doesn’t always work out the way you might think.  And, I don’t perform house calls.

Now, once you’ve got all that taken care of, students need to submit their programs.  We have a variety of ways to do that now.  We have a homework drop through our SIS (RenWeb) and I also use Google Classroom.  One works great with offline (local) files and the latter works well with local or files in their Google Drive (we are a Google Apps for Education school).

So, given all these coding, compiling, transferring, and submission requirement, I wanted to find a simple way for my students to accomplish each in a browser.  I’ve tried to find this several times in the last few years, especially last year when I did a Chromebook pilot with my AP CS A students.  However, there were no simple comprehensive solutions to be found.  This year I was determined to come up with something.  I did.  Its not as pretty or simple as I’d like, but I think it will work.  If you’ve been struggling with the same issue, perhaps this will help.  If you’ve already found a better solution, and you are laughing condescendingly at me as you read this, I beg of you, please share your solution.

Before I detail the solution I’ve pieced together, let me also mention some other tools that I’ve come across that I believe are of some merit.  You may be using these already or may find a place for them in your own curriculum.

TutorialsPoint – Java Compiler & Editor

TutorialsPoint has a great online editor and compiler that I’ve used on many occasions.  The user interface is quite pleasant and simple to use.  To be honest, I use this often when I want to quickly compile and execute a block of code that I’m inserting into a document.  I like that you can import projects from elsewhere (e.g. Dropbox, Google Drive).  However, I’ve never felt like this is a complete solution as there was (at the time of this writing) to store any settings.  Also, I’ve found the compile button awkward and confusing if you are not using the initial HelloWorld.java file they provide.  The use of the prompt in a lower window is nice if you know how to use it; most of my students do.

Koding.com

I used Koding.com in 2014-15 with my AP CS A students during a brief Chromebook pilot program.  The greatest part of Koding.com, for us, was the editor.  It was quite pleasant to the eye (something quite important to several students in that class) and had some great shortcuts, but it lacked integration with our cloud storage solutions.  Though I had to introduce my students to a little Linux shell usage, compiling and running applications was not overly difficult because they were used to learning some DOS prompt commands to do the same on our Windows machines.  File submission was also difficult, so ultimately enabled FTP services on a server I had running and taught them how to submit their files via FTP.  Most of my students that year were tech savvy, so it wasn’t difficult.  However, it was a bit of a pain for me to setup, teach, and then retrieve assignments.

 

So, given the limitations of these tools, I purposed to find another more comprehensive solution.  Here’s what I came up with in January, 2016.

Codeanywhere.com & Dropbox

I entertained a lot of online coding sites (e.g. Cloud 9, Koding, Codenvy, etc.) but most either lacked Java support or were way over the top for student use.  The one I liked best for student use was Codeanywhere, but it wasn’t without some issues that had to be overcome.  However, I could overcome each of these issues in a single period with my students, then they were set for the remainder of the year.

The first issue was integrating our cloud storage solution, Google Drive.  For some reason, at testing time, I couldn’t transfer files to/from the Google Drive integration (or “connection” as it is called in Codeanywhere).  So, I took advantage of Dropbox which my students could get for free using their Google accounts.  That integration (or “connection”) worked flawlessly.

The second issue was a compiler. I would love for an online solution to have simple a compile feature (e.g. a button) that compiles your file automatically (like a true IDE) or your entire project, but I cannot seem to find an online solution build toward this end. However, Codeanywhere allows for you to connect your own little server (“stack”) that can be used toward this end.  It required a little setup and a manual installation of Java, but after that, it was fairly straightforward for my students to use.

Now that each of these issues was tackled and setup, my students can now virtually code from anywhere.  They can login to Codeanywhere.com via their Google accounts and there they have their Dropbox files and a little server to compile on.  They simply create a file on the server, code, compile, and test.  When they’re done, they can simply drag/drop their files to Dropbox and their ready to submit via our homework drop, Google Classroom, or the latest solution I’ve been testing (Schoology, which has Dropbox integration).  Here’s how we set it up.

1. Sign Up for Free Dropbox Account

Navigate to dropbox.com and sign up for free.  There we used the Sign up free with Google option.  You’ll be able to setup an account for free, but you’ll need to create a password for use Dropbox (no Single Sign-On).  When you’re done your browser will likely download the Dropbox application for your machine, but you don’t need to install it (and probably won’t want to in a lab environment).

 

2. Sign Up for Free Codeanywhere Account.

Navigate to codeanywhere.com and sign up for free (there are paid accounts as well).  There we again used the Google integration in order to sign up.  After signing up and logging in, you’ll be prompted to add some connections.  The first connect we made was our Dropbox connection.

 

3. Connect Dropbox Account

You should now be looking at the Connection Wizard that appears upon first login.  If you don’t see it, right-click on ‘Default’ in the file explorer on the left, then choose ‘New Connection’.  Choose the ‘Dropbox’ connection in the left sidebar.  Then click ‘Add Your Dropbox Account’.  Note, your browser may block the opening of a new window/tab, so pay close attention to the top-right part of your screen; you may need to allow the pop-ups from codeanywhere.com and then click the link again.  Once the page loads, enter your Dropbox credentials and allow the integration.  Once this is done, you’ll see your Dropbox account listed in the file explorer under ‘Default’.

 

4. Add a Server

In the Connection Wizard window, choose ‘Container’ at the top (it may already be selected).  This will allow you to add a “stack” which is essentially a stack of code that is ready to run on a server for the purposes of development.  There are some preset stacks made for a number of development platforms (e.g. PHP, Ruby, Node.js), but nothing for Java (at this point).  So, we are going to create our own.

Choose ‘Blank’ from the menu, there is likely more than one, I chose the stack installed on Ubuntu.  Give the stack a name at the top.  I called mine ‘JavaServer’.  Then, click create.  The Connection Wizard will now close and you should see your new server being configured/started on the left.

Note, these are the only two connections we’ll be allowed to add in our free account.

 

5. About the Server

If you click on the server we just created, you may see a .git folder inside.  If you are familiar with Git, then you’ll know exactly what this is.  Either way, we’re not using Git at all, so you can just delete it.

The .git folder (that you may have just deleted) is, at the present, the only folder inside your “workspace” directory.  The file explorer will show you only what is in this folder, even though we truly have access to the entire server.  But, truth be told, all this really isn’t important, especially if you’re not familiar with administering a Linux-based server.

 

6. Install Java

Since we chose a blank development environment, we’re going to need to get things started in order to program in Java. Right-click on the server you created and choose ‘SSH Terminal’.  This will open a new space with a terminal (like a command prompt).  Note, we’ve noticed that after you create your server, the right-click menu doesn’t work.  Signing out, then back into Codeanywhere usually remedies this.

From the terminal we are going to install Java.  To do that we are going to issue a few commands and do a little waiting.  They are not overly difficult, and you don’t even need to know what they do.

First, we are going to issue the command: sudo apt update

sudo tells the server to perform the command as a super user (super user do).  apt (short for aptitude) is a package manager found on many Linux distros (distributions).  update is an apt command that instructs the application to update package list. This should only take a few seconds.  You’ll see some activity on the terminal while it is working.

Next, we are going to install Java with the command: sudo apt-get install default-jdk

This command will output a number of lines and conclude with a confirmation prompt.  You can simply hit enter to continue the installation.  This will take a little longer, maybe up to a minute or two.  Just let it run. On a side note, the command essentially is telling apt to install a default Java Development Kit package so that we can develop in Java.  Once it is done, we should be back at the normal prompt.  You can use the clear command to clean up the terminal if you’d like.

 

7. Test Java Install

To test the Java install, you can simply issue the command: java

If you get feedback, other than a message about the command not being found, you should be ready to go.

 

8. Create a Test Application

There are a number of ways to create a file using the terminal, but since most of my students are click-happy, so we’ll use the mouse.  Right-click on the server and choose ‘Create File’.  This will present you with a file dialog box, add the name of a Java application.  I’m going to use HelloWorld.java.

After pressing OK, or hitting enter, your new file will appear in the file explorer area as well as open up as a tab for coding.  Go ahead and code a sample program. When finished, save the file.  Note, there are a number of keyboard shortcuts that are available to be used in Codeanywhere (e.g. CTRL-S to save).

 

9. Compile Test Application

Once you’ve finished coding your test application and saving it, you’re ready to compile.  Go to the terminal, and type the command ls to verify that you’ve saved your file.  If you did, you should see the name of the file come up.  Note ls is a command in linux that is used to list folder contents.

If for some reason you (or a student) got a little crazy on the terminal and navigated away from the workspace directory, you can issue the following command to get back: cd ~/workspace

Now that you’ve verified the file is there, you can compile it with the javac command: javac HelloWorld.java

No feedback is what we’re looking for.  So if you received some errors, go fix them.  Don’t forget to save your changes though.

 

10.  Run Application

Once the application compiles, you can run it.  Use the java command for this: java HelloWorld

 

11.  Copy File to Dropbox

If you click and drag your file from the server to your Dropbox, it will actually MOVE the file.  So, you may want to right-click and choose ‘Copy’, then right-click on your Dropbox and choose ‘Paste’.