Difference between revisions of "Installing JDK and DrJava"

From CompSciWiki
Jump to: navigation, search
m (Changed a bit of the wording about TextPad)
(Remove TextPad material.)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Template:1010Topic
 
{{Template:1010Topic
|Chapter_TOC=[[What is Programming?]]
+
|Chapter_TOC=[[Getting Started]]
|Previous=[[What is Programming?]]
+
|Previous=[[Setting up your own computer]]
|Next=[[Anatomy of a Program]]
+
|Next=[[Setting up your own computer]]
 
|Body=
 
|Body=
  
Line 8: Line 8:
 
To start programming in Java, you will need to install the Java Development Kit (JDK) first.You will also need to install a development environment where you can write and run your Java programs. The development environment you need to install depends on the operating system your computer runs on. This section is subdivided to guide you through installing the right software for your computer.
 
To start programming in Java, you will need to install the Java Development Kit (JDK) first.You will also need to install a development environment where you can write and run your Java programs. The development environment you need to install depends on the operating system your computer runs on. This section is subdivided to guide you through installing the right software for your computer.
  
==Installing Java SDK==
+
==Installing the JDK==
Follow the instructions for your operating system.
+
 
 +
Below are the instructions for setting up the JDK for various operating systems you may be using. Consult your professor if you cannot get the JDK working.
  
 
===Windows===
 
===Windows===
'''NEW!***When the Java website asks you for your operating system, choose 'Windows'. Do NOT choose 'Windows 64-bit'.  
+
Click on the link below, and then click on the large button at the top indicating Java Download (not NetBeans). When the Java website shows you a selection of operating system versions, choose 'Windows x86'. Do NOT choose 'Windows x64'. (This version will work on most new Windows computers, but it does not interact well with QuickTime and with TextPad. We recommend the Windows x86 version to avoid dealing with problems that might arise.)
Install the Java Developer's Kit (JDK). The JDK allows your computer to create and run Java programs. There is a problem with the Windows 64-bit version of JDK, QuickTime, and TextPad. The easiest solution is to just go back to the 32-bit version of JDK.'''
+
Install the Java Developer's Kit (JDK). The JDK allows your computer to create and run Java programs. It also includes the Java Runtime Environment (JRE) which can be used in browsers.
  
 
* JDK Download and installation: http://java.sun.com/javase/downloads/index.jsp
 
* JDK Download and installation: http://java.sun.com/javase/downloads/index.jsp
  
===Mac OS X (Lion)===
+
After you have installed the JDK, go to the site below and download the Windows version of DrJava. For a guide on using DrJava, simply click on the "Documentation" or "QuickStart Guide" link on the lefthand side pane on http://drjava.org/. Note that the file you download is an exe file that can be installed anywhere (e.g., your Desktop or the folder where you keep your COMP 1010 java files.)
 
+
The newest version of Mac OS, Lion does not include Java. You can download it here: http://support.apple.com/kb/DL1421.
+
 
+
===All other Mac OSs===
+
 
+
Java is already installed! All you'll need to do is install Dr. Java.  
+
 
+
==Second Step: Install Dr Java==
+
 
+
We'll be using DrJava as the development environment for this course.
+
 
+
Below is the link to download JDK and installation instructions.
+
  
 
* DrJava Download and Installation: http://drjava.org/
 
* DrJava Download and Installation: http://drjava.org/
  
For a guide on using DrJava, simply click on the "Documentation" or
+
===Mac===
"QuickStart Guide" link on the lefthand side pane on http://drjava.org/
+
  
 +
The newest version of Java in 2014 is Java 8. Mac computers used to come with Java installed, but it was Apple's own version, obtained from Apple, not from Oracle. Apple stopped developing Java versions at Java 6. If you install the DrJava application below, it will demand Apple's version 6 of Java, which can be downloaded from this site:
  
==Alternate Development Environment: TextPad==
+
* Apple version 6 of the JDK: http://support.apple.com/kb/DL1421.
  
Some students may wish to program using TextPad (instead of Dr. Java). The following instructions are for students using TextPad with the JDK. There is no penalty for choosing to use TextPad instead of DrJava.
+
Apple's version is fine for developing code in this course, but it explicitly prevents your browser from running Java apps. There have been a lot of bugs found in the Java Runtime Environment (JRE), which is included in the JDK. Any older version of the JRE (such as Apple's) is not safe to use in a browser. Instead of trying to fix the bugs, Apple just prevented browser use.  
  
===Installing TextPad===
+
However, if you go through the same procedure as Windows users above, you can download and install version 8 of the JDK for Mac OS X from Oracle in the same way as you download a Windows version. You cannot easily use this version with DrJava, but it can co-exist with the Apple version of Java, and it can support Java applications in your browser.
  
After installing JDK you are now ready to install a development environment. A development environment is where you do the actual writing and running of your programs.
+
After you have installed Apple's version of the JDK, go to the site below and download the Mac version of DrJava. For a guide on using DrJava, simply click on the "Documentation" or "QuickStart Guide" link on the lefthand side pane on http://drjava.org/, though there is not much information about the Mac version specifically.  
  
Most students install the [[Glossary#textpad | textpad]] development environment, as that is the environment used in class by most instructors. Note that Textpad is shareware, and you are expected to purchase a copy if you intend to keep on using it. You may instead download the Windows version of the free DrJava package as described above for Mac users.
+
* DrJava Download and Installation: http://drjava.org/
 
+
'''IMPORTANT:''' Install the JDK first! If you install it after you have already installed Textpad, you will need to manually set up Textpad to compile and run Java programs.
+
 
+
Below are the links to download Textpad and installation instructions.
+
 
+
* Textpad Download: http://www.textpad.com/download/index.html#downloads
+
* Installation: http://www.textpad.com/download/index.html#instructions
+
 
+
Here's a short [[Guide to TextPad]].
+
 
+
===Common Problems with JDK and TextPad===
+
 
+
====TextPad Does Not Have the Options to Compile and Run, or These Options are Present But do Not Work====
+
'''NEW!*** When you were installing JDK did you chose 'Windows' or 'Windows 64-bit'? If you chose Windows 64-bit, uninstall JDK, then reinstall it, choosing just 'Windows'. There is a problem with the Windows 64-bit version of JDK, QuickTime, and TextPad. The easiest solution is to just go back to the 32-bit version of JDK.'''
+
 
+
First, make sure that you have installed the JDK. If it is not installed when you install TextPad, TextPad will not be able to set up the compile and run commands. Then you have two options: 1) Re-install TextPad or 2) Add JDK commands using the menu. There is also a third option involving changes to Windows configuration that you may find on the internet, but this option varies somewhat depending on your version of Windows, so we will address only these two choices here.
+
 
+
STEP 1: Add JDK commands using the TextPad menu
+
In TextPad, follow these steps if the compile and run options do not appear (see below if they appear but do not work):
+
# Click on Configure, then choose Preferences
+
# Select Tools (from Preferences dialog box)
+
# Click Add
+
# If "JDK Commands" appears on the drop down menu, select it and click Apply or OK. (See picture below.)
+
 
+
[[Image:javacommands.jpg]]
+
 
+
STEP 2: Reinstall TextPad
+
Uninstall Textpad, and install it again.
+
To uninstall Textpad:
+
# Click on the Start button at the bottom left corner of the screen.
+
# Click Control Panel
+
# Double click on Add or Remove Programs (the name is slightly different in some versions of Windows)
+
# Scroll down the list until you find Textpad
+
# Click on the Change/Remove button
+
# Follow the prompts to uninstall Textpad
+
 
+
STEP 3: If you're still reading, it probably means you've reinstalled TextPad, then tried to add the "JDK Commands"  and they still do not appear. Next? Install working compile and run commands from scratch:
+
 
+
# Click on Configure, then choose Preferences
+
# Select Tools (from Preferences dialog box)
+
# Click Add
+
# Choose Program... and then use the file selection window that opens up to find the javac command.  It will be in C:\Program Files\Java\jdk...\bin (where the ... means some version number). Click on javac and then click on Open. A new tool called Javac should appear in the list of tools. Click on Apply to make it permanent. Javac is your new compiler tool.
+
# Create a run tool in the same way, but this time select the file java instead of javac.  The new run tool will be called Java. Make sure you click on Apply.
+
# Then click on the + beside Tools in the Preferences dialog box to show Javac and Java below it. Select each one in turn and make sure the rest of the settings are correct.
+
# Javac: Parameters should be $File and Initial Folder should be $FileDir. You may want to click on "Capture Output" and/or "Sound alert when completed" as well.
+
# Java: Parameters should be $BaseName and Initial Folder should be $FileDir. You may want to click on "Capture Output" and/or "Sound alert when completed" as well. It should look something like the following:
+
 
+
[[Image:JavaTool.png]]
+
 
+
 
+
===Textpad doesn't use colour for key words===
+
First, make sure you have the JDK commands under the tool menue (see above help item). Next, turn on the Java syntax highlighting:
+
#Click on Configure, then Preferences.
+
#Click on the + beside Java.
+
#Select syntax
+
#Check the box 'Enable Syntax Highlighting' and choose java.syn as the Sytnax Definition File
+
 
+
====I Get A Popup When I Try To Save====
+
If you get a popup that asks if you would like to register or continue evaluation, simply click on "Continue Evaluation". The trial period of Textpad will never run out.
+
 
+
====Sample Code Does Not Compile====
+
If your instructor has given you a code example which does not compile on your machine, you may have a different version of the JDK than they do. Please contact your instructor for instructions on getting the code to compile.
+
 
+
====My java program compiles fine, but I get a "NoClassDefFound" error when I try to run it====
+
 
+
Windows machines have what is called a "classpath" environment variable. When you try to run a Java program from your development environment (like TextPad), the classpath variable tells your system what directories / folders to look in for files (or classes) to run.
+
 
+
Usually, the classpath environment variable is set so that one of the places that will be searched is your "working folder / directory". Your working folder / directory is where you are saving all your files containing Java code.
+
 
+
Some software (Adobe products like Photoshop often seem to be the culprit) modify this environment variable so the working directory / folder is never actually checked for the classes you are trying to run. The end result is that when you try to run your program, you get a "NoClassDefFound" error.
+
 
+
This is an annoying problem. Fortunately, it is usually easy to fix.
+
 
+
'''The solution?''' Add a ";." (that's a semi-colon followed by a period) to the end of your  classpath  environment variable. The ";" separates the "." from the other directories / folders, and the "." specifies to look in the working directory.)
+
 
+
If you have the NoClassDefFoundError, take a look at your  classpath  environment variable (if you don't have one, then you likely don't have the problem described here) and see if that period is there. If not, follow the steps for the appropriate version of Windows.
+
 
+
'''Note: Be careful; making a mistake with your system variables can disable your entire machine.'''
+
 
+
Changing your classpath in Windows Vista:
+
  
<OL>
+
Note that the file you download is a tar.gz file. That means it is a compressed file. If you double-click on this file, built-in utilities on your Mac should produce a DrJava.app file in the same folder. This file can then be moved anywhere (e.g., your Desktop, or Applications, or the folder where you keep your COMP 1010 java files.)
<LI> Click on START (lower left)</LI>
+
<LI>Click on "Control Panel".</LI>
+
<LI>Select "Classic View". </LI>
+
<LI>Double-click on the "System" icon.</LI>
+
<LI> Click on the "Advanced system settings" link.</LI>
+
<LI>User Account Control may ask you for permission to continue. Select "Continue". </LI>
+
<LI> Click on the "Environment Variables" button (near bottom).</LI>
+
<LI>Highlight  CLASSPATH and click the "edit" button.</LI>
+
<LI>Add a semi-colon and a period (";.") to the END of the existing  CLASSPATH. Alternatively, you can add a ".;" to the BEGINNING of the existing CLASSPATH. </LI>
+
<LI> Exit the control panel. If the class problem persists, restart your computer. </LI></OL>
+
  
 +
To use DrJava on a recent Mac, you may need to adjust your Security Settings. If you don't, you may get an error "DrJava is damaged and can't be opened. You should move it to the Trash." This message is incorrect and misleading. It really means that your security settings prevent the operating system from opening a file that doesn't come from a developer on an internal developers list. Open your Settings and click on "Security & Privacy". If the lock at the bottom of the window is closed, click on it and provide your password to allow changes. Then change the setting to "Allow apps downloaded from: ... Anywhere". (Once you have used DrJava once, you can change this setting back to its original value if you want.) Right-click on DrJava.app and choose Open. Now you will likely get a message about it being from an unrecognized developer. Click on the Open button provided, and it should work. This rigmarole will only be required once.
  
Changing your  classpath in Windows NT, 2000 and XP
+
==Alternate Windows Development Environment: TextPad==
  
<OL>
+
Some students may wish to program using TextPad (instead of Dr. Java). The following instructions are for students using TextPad with the JDK. There is no penalty for choosing to use TextPad instead of DrJava. See [[Installing and Using TextPad]].
<LI>Click on START (lower left).</LI>
+
<LI>Click on "Control Panel" (You may find the Control Panel directly off the start menu, or you might have to click on "Settings")</LI>
+
<LI>Double-click on the "System" icon.</LI>
+
<LI>Click on the "Advanced" tab.</LI>
+
<LI>Click on the "Environment Variables" button (near bottom).</LI>
+
<LI>Highlight "CLASSPATH and click the "edit" button.</LI>
+
<LI>Add a semi-colon and a period (";.") to the END of the existing CLASSPATH. Alternatively, you can add a ".;" to the BEGINNING of the existing CLASSPATH. </LI>
+
<LI>Exit the control panel. If the class problem persists, restart your computer.</LI>
+
</OL>
+
  
  
Windows 98
 
<OL>
 
<LI>Click on START.</LI>
 
<LI>Select RUN.</LI>
 
<LI>Type in sysedit, then click OK. </LI>
 
<LI> The system editor starts up with several windows showing. Go to the window that is displaying AUTOEXEC.BAT.</LI>
 
<LI>Look for the CLASSPATH</LI>
 
<LI>Edit the  CLASSPATH  statement by Adding a semi-colon and a period (;.) to the END of the existing  CLASSPATH</LI>
 
<LI>Close the AUTOEXEC.BAT window. If the class problem persists, restart your computer.</LI>
 
</OL>
 
 
}}
 
}}

Latest revision as of 12:10, 21 August 2014

COMP 1010 Home > Getting Started


Introduction

To start programming in Java, you will need to install the Java Development Kit (JDK) first.You will also need to install a development environment where you can write and run your Java programs. The development environment you need to install depends on the operating system your computer runs on. This section is subdivided to guide you through installing the right software for your computer.

Installing the JDK

Below are the instructions for setting up the JDK for various operating systems you may be using. Consult your professor if you cannot get the JDK working.

Windows

Click on the link below, and then click on the large button at the top indicating Java Download (not NetBeans). When the Java website shows you a selection of operating system versions, choose 'Windows x86'. Do NOT choose 'Windows x64'. (This version will work on most new Windows computers, but it does not interact well with QuickTime and with TextPad. We recommend the Windows x86 version to avoid dealing with problems that might arise.) Install the Java Developer's Kit (JDK). The JDK allows your computer to create and run Java programs. It also includes the Java Runtime Environment (JRE) which can be used in browsers.

After you have installed the JDK, go to the site below and download the Windows version of DrJava. For a guide on using DrJava, simply click on the "Documentation" or "QuickStart Guide" link on the lefthand side pane on http://drjava.org/. Note that the file you download is an exe file that can be installed anywhere (e.g., your Desktop or the folder where you keep your COMP 1010 java files.)

Mac

The newest version of Java in 2014 is Java 8. Mac computers used to come with Java installed, but it was Apple's own version, obtained from Apple, not from Oracle. Apple stopped developing Java versions at Java 6. If you install the DrJava application below, it will demand Apple's version 6 of Java, which can be downloaded from this site:

Apple's version is fine for developing code in this course, but it explicitly prevents your browser from running Java apps. There have been a lot of bugs found in the Java Runtime Environment (JRE), which is included in the JDK. Any older version of the JRE (such as Apple's) is not safe to use in a browser. Instead of trying to fix the bugs, Apple just prevented browser use.

However, if you go through the same procedure as Windows users above, you can download and install version 8 of the JDK for Mac OS X from Oracle in the same way as you download a Windows version. You cannot easily use this version with DrJava, but it can co-exist with the Apple version of Java, and it can support Java applications in your browser.

After you have installed Apple's version of the JDK, go to the site below and download the Mac version of DrJava. For a guide on using DrJava, simply click on the "Documentation" or "QuickStart Guide" link on the lefthand side pane on http://drjava.org/, though there is not much information about the Mac version specifically.

Note that the file you download is a tar.gz file. That means it is a compressed file. If you double-click on this file, built-in utilities on your Mac should produce a DrJava.app file in the same folder. This file can then be moved anywhere (e.g., your Desktop, or Applications, or the folder where you keep your COMP 1010 java files.)

To use DrJava on a recent Mac, you may need to adjust your Security Settings. If you don't, you may get an error "DrJava is damaged and can't be opened. You should move it to the Trash." This message is incorrect and misleading. It really means that your security settings prevent the operating system from opening a file that doesn't come from a developer on an internal developers list. Open your Settings and click on "Security & Privacy". If the lock at the bottom of the window is closed, click on it and provide your password to allow changes. Then change the setting to "Allow apps downloaded from: ... Anywhere". (Once you have used DrJava once, you can change this setting back to its original value if you want.) Right-click on DrJava.app and choose Open. Now you will likely get a message about it being from an unrecognized developer. Click on the Open button provided, and it should work. This rigmarole will only be required once.

Alternate Windows Development Environment: TextPad

Some students may wish to program using TextPad (instead of Dr. Java). The following instructions are for students using TextPad with the JDK. There is no penalty for choosing to use TextPad instead of DrJava. See Installing and Using TextPad.

Previous Page: Setting up your own computer Next Page: Setting up your own computer