Chapter:Setting up your environment

From Juneday education
Jump to: navigation, search

Meta information about this chapter

Expand using link to the right to see the full content.


Having a development environment is crucial when developing. This chapters tells you how to install a shell, a Java compiler, a Java runtime environment and an editor.


Make sure every student have a development environment setup.


No educational goals.

Instructions to the teacher

Common problems

It is very important that all students complete this chapter in due time, since the rest of the chapters requires that the tools are in place (and all examples are using these tools). Also, this book is based on exercises and without a functional environment the students won't be able to do the exercises.

It is common for students using windows to get confused by Window's default setting "hide extension for known file types". It is good to turn that option off, so that extensions are always shown. This will hopefully avoid situations such as students ending up with file names such as "" while seeing only "".

Also, beware that students often fail to understand the concept of the PATH environment variable as well as the Java concept of CLASSPATH. Also, please not that the classpath on Windows is using the ; (semicolon) as a separator, while it is possible that the videos are showing examples from GNU/Linux which is using : (a colon) as separator. Lastly, Windows is prone to use spaces in directory names (and file names) so be aware that this might pose a problem for the students. The solution is usually to put double quotes around the PATH or class path etc.

When we installed Java SE 8 on a Windows 10 platform, the installer didn't set the PATH to the JDK bin folder. It did set the PATH to the JRE so running java on the command line worked fine, but running javac did not!

Also, we recommend using a text editor such as Atom (since we don't teach IDEs and we definitely don't want to promote using notepad!). When we installed the Atom editor, again, the installer didn't set the PATH to the editor and it was actually some work to figure out where it was installed...

Your environment

Your environment for the Programming with Java programming book consists of these parts:

  • Additional software (see below)

Additional software for prog-java

Automatic installation of additional software

You will also need some additional software in this course which you can install in any of the two ways using a terminal:

Download script and execute
  1. Download our boot strap script for this course
    curl -o
  2. make the script executable
    chmod a+x
  3. and execute it (with verification - recommended)
    ./ --verify to skip verification, simply enter ./
Execute from web

curl | bash

Manual installation of additional software

The script above uses files containing a list of packages to install. Here are links to the packages file for each platform we support. Install the packages in these files:

Questions and Answers

Expand using link to the right to see the full content.

Q: “You have chosen to use a terminal and this bash shell thing, throughout the course. What’s the reasoning behind that? Aren’t there any fancier tools for programming in Java?”
A: We don’t know about fancy, but we have some reasons behind choosing command line (a terminal window where you enter commands interpreted by a shell like ‘bash’) together with a texteditor as the programming environment and tools. First, learning a shell like bash is a very useful skill when working with programming and with computers in general. Being confident about using the shell and terminal let’s you learn about the file system, files, the standard streams for output and input, paths, and some environment variables like the PATH variable. The environment for the command line we have chosen (bash or bash via Cygwin) is the standard command line interface for UNIX, GNU/Linux and Mac OS. Being familiar with the bash shell (command interpreter) will prepare you for working with servers and other systems that are running quite a few different operating environments. Also, since we expect all students to run and use bash inside a terminal, all the examples will look the same and we don’t have to provide examples for three (or more) different types of systems.

Using a text editor stresses the fact that a Java source code file is nothing magical but rather a simple text file. Having limited support from “fancy” helper features like “code completion” and other stuff typically found in the fancier tools, forces the students to carefully think about what they are typing in. If a student gets stuck and can’t remember some names etc from the Java class library (Java comes with a huge library of pre-written code that you can use!), the student must look this up, which fosters skills also for getting information and researching the Java class library. Hopefully, the student will better remember what to type after having to look it up, which may not be the case if the fancy tools writes the code for her at the click on a magic button etc.

Also, knowing how to use a decent text editor is a very useful skill! A text editor can be used to write code in any programming language, and, of course, to write and edit text files of any general purpose (such as changing configuration files etc). Using a fancy programming tool gives the students experience of a piece of software with limited applicability outside the realm of writing programs. And it is not unusual that a programming tool only supports one or a few programming languages or suites.

Since this is an introductory course, we wanted to focus on not only the theory and syntax behind the Java programming language, but also on the practice of writing programs. The practice is to author code, save (and organize) the code in files and directories, compile the code and lastly run it. Using a tool that at the same time is used to edit and write code, compile the code and often even running the code, does not make this practice very clear. Using our philosophy of using only the basic tools (terminal, editor, compiler, Java Virtual Machine) prepares the students for using any other tool at a later stage in their career or continued studies. If you only know how to program using one particular all-in-one programming tool, you are quite dependent on that tool being installed everywhere you want to create programs (and even run programs!). We try to avoid such a situation.

Lastly, we have seen that some aspects of the Java programming languages that has to do with so called packages (Java compilation units/classes that are grouped together inside a directory) and paths are not very intuitive when using a fancy tool for the programming activity. In fact, many fancy tools for creating Java programs efficiently hide what’s going on from the user. While this may be OK for an experienced programmer, it stands in the way of the novice programmer who is struggling to understand what packages are, how to declare them and where to put the files, how to compile programs using packages, and how to write code that imports names from a package written by the programmer herself.

Q: “But there are fancy tools then?”
A: Yes! There are quite a few fancy tool that you are free to explore on your own. We will probably not be able to help you solve any problems related to the use of any one particular tool, however, which is why we try to steer all the students into using very similar tools for the practice of programming in this course. Fancy tools (also known as IDE - integrated development environments) include Eclipse and NetBeans.

Q: “So the practice of programming is basically these activities: Edit/save, compile, run?”
A: Yes! However, typically you first analyse what your program should do, what restraints are there and what requirement exist. Then you model the things your programming is managing and lastly you write code to implement how the program will use the things in order to perform the task which the program is there to do. When the actual coding has started, there is typically a cycle of “edit-change, compile, run” which is repeated until you have a functional program. On top of this, it is very common that the programmer also documents the code that is written (so other programmers later can understand how the program and code works) and sometimes even writes a more high-level documentation of the system and even a manual.

The analyses and design are material for a later course and will not be the focus of this course. Writing documentation will be touched upon and that too is something for later courses.


Where to go next

Next pages is: Programming in Java

« PreviousBook TOCNext »