All pastes #948362 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-03-19 01:57 UTC
rendered paste body
Dear Students,

Here is a description of some Eclipse setup that I intended to cover in class today.

In Eclipse, you should already have a project named labs. This labs project corresponds to a folder with the same name labs that exists inside your Eclipse workspace folder. Use the Windows Explorer (the file manager) to find these folders.

Using Eclipse, make a new package lab7 inside your labs project. In the Windows Explorer, you should now see a folder lab7 inside the folder labs.

Drag edu_mines_jtk.jar into your labs (not lab7) folder.

Drag the three files gugg.gif, Lab7.txt and PhotoPlay.java into your
lab7 folder.

Select the lab7 package in Eclipse and do a Refresh (F5). You should now see the three files in Eclipse.

Open PhotoPlay.java in the Eclipse editor. You should see errors, beginning with the statements import edu.mines.jtk.awt.*; import edu.mines.jtk.mosaic.*;

These statements import classes from packages that are inside edu_mines_jtk.jar. These are not standard Java packages, so we must tell Eclipse where to find them.

In the Eclipse Package Explorer pane (the left pane), right-click on your labs project and select Properties from the pop-down menu.
Alternatively, you can select Properties from the Eclipse Project menu. Either way, you should see a dialog box "Properties for labs".

The property we want to modify is Java Build Path. Select this property in the pane on the left side of the dialog box. Then in the right pane select the Libraries tab. Click the button Add External JARs ... and use the file selector to choose edu_mines_jtk.jar, which you put inside your labs folder. Click OK to exit the Properties dialog box. If you Refresh in Eclipse, you should see edu_mines_jtk.jar in your labs project.

The compile errors for PhotoPlay.java should now be gone. So try running the program.  You should get an error: Must specify names of one or more image files!
Look at the program PhotoPlay.java and find the statements that generate this error. PhotoPlay looks in the array String[] args for names of image files. So we must configure the way we run this program in Eclipse to specify at least one such file.

In the Eclipse Run menu, and with PhotoPlay selected, choose the Open Run Dialog ... item. With this dialog you can specify lots of parameters that control the way Eclipse runs your programs. In the Main tab, you should see your project labs and main class lab7.PhotoPlay.

Select the (x)= Arguments tab. In the Program arguments, enter the filename lab7\gugg.gif. Then click the Run button. You should see four identical images displayed. Identical, because PhotoPlay is incomplete.

If you get some "IIOException Can't read input file!", then you need to reconfigure your Program arguments in the Run Dialog. (On my Mac, I need lab7/gugg.gif instead, and this might work on Windows as well.) The reason you need to specify the folder lab7 is because this file name is found relative to your Working directory, which by default is your labs project folder. If you like, you can change this default.

Eclipse will remember the Arguments setting, so you need not specify these arguments again every time you Run.

Would you please send me an email message when you get this to work?

Thanks,
Dave