9/21/2011

Where to Get

• Eclipse for EE Developers – http://www.eclipse.org/downloads/ Java IDE Eclipse • Eclipse Classic 3.7 • Unzip to a location of your preference IS2470 Interactive Systems – Launch Eclipse.exe (Eclipse.app) Design (Fall 2011) • First time you launch Eclipse – Specify a “workspace” folder for all projects – Avoid spaces on the path to workspace

Michael V. Yudelson (C) 2010 2

What to do with Eclipse Anatomy of a Project

• Creating a Project • Project root folder - / • Adding a Class to a Project – Subfolder of Eclipse workspace folder – E.g. C:\Java\Eclipse\workspace\proj1 • Adding a File to a Project • Source code (.java) - /src • Advanced Views • Compiled code (.class) - /build • Compiling • Files to be deployed to the - /web • Running and Debugging • In project root do not delete • Miscellany – .classpath, .project files, .settings folder

Michael V. Yudelson (C) 2010 3 Michael V. Yudelson (C) 2010 4

1 9/21/2011

Creating a Project Adding a Class to a Project

• File->New->Project • File->New->Class – Select “Java Project” – Source folder /{project_root}/src/ – Click “Next” – Specify Class Name – Enter project name – Specify super-class – Click “Next” • Click “Browse” to search for super-class (e.g. ) – Build folder /{project_root}/build – Click “Finish” – Source folder /{project_root}/src – Click “Finish” • Unfortunately no default WYSIWYG editor for Applet controls

Michael V. Yudelson (C) 2010 5 Michael V. Yudelson (C) 2010 6

Adding a File to a Project Advanced Views

• File->New->Other… • Window->Show View->… – Enter search word under “Wizards” – Outline - list of class members and • E.g. HTML methods – Follow the dialog flow – Console - console output – Problems - list of errors and warnings with explanations • All Views are Dockable

Michael V. Yudelson (C) 2010 7 Michael V. Yudelson (C) 2010 8

2 9/21/2011

Compiling Running

• Saving a file - compiles it automatically • Running a Class – Provided there are no errors – Must have main() method or be an applet • Compiled .class file – Right-click->Run As->… e.g. as applet – Usually {project_root}/build/ • Preview HTML page – Packages add sub-folders to this path – Right-click->Open With->Web browser • E.g. class edu.pitt.sis.paws.kt.Visualizer • Source {project_root}/src/edu/pitt/sis/paws/kt/ • Code {project_root}/build/edu/pitt/sis/paws/kt/

Michael V. Yudelson (C) 2010 9 Michael V. Yudelson (C) 2010 10

Debugging Miscellany

• To debug • Annotations – Insert breakpoint (doubleclick in line gutter) – ! - warnings in the code – Right-click->Debug As->… e.g. as applet – X - errors in the code – Opens “Debug perspective” (top right) – All errors and warnings in all your projects • Return to Java perspective to resume editing are listed in Problems view • Variables view - current variable values • Renaming class file • Run menu - stepping through the code – Rigth-click->Refactor->Rename

Michael V. Yudelson (C) 2010 11 Michael V. Yudelson (C) 2010 12

3 9/21/2011

Miscellany (cont’d) Miscellany (cont’d)

• Packages – structural organization of • Do not use packages  (yet) the code • Package nesting mapped to folder structure – java.aplet.*, java.applet.Applet – edu.pitt.sis.adapt2.is2470.SomeClass – /src/edu/pitt/sis/adapt/is2470/SomeClass.java – org.apache.catalina.*, – /build/edu/pitt/sis/adapt/is2470/SomeClass.class org.apache.catalina.SessionEvent • To get access to SomeClass – edu.pitt.sis.adapt2.kt2.* – include edu.pitt.sis.adapt2.is2470.* OR • Similar to domain names in reversed – include edu.pitt.sis.adapt2.is2470.SomeClass order

Michael V. Yudelson (C) 2010 13 Michael V. Yudelson (C) 2010 14

Miscellany (cont’d) Miscellany (cont’d)

• Eclipse reports a problem of • Adding JAR libraries synchronization with – JAR – Java ARchive (zip’d class files in folders) – Select the project item in the Project Explorer tree – Project menu->Properties – Right click -> Select Refresh(F5) – Java Build Path item in the list on the left – Everything should be fine – Libraries tab – Add External JAR

Michael V. Yudelson (C) 2010 15 Michael V. Yudelson (C) 2010 16

4 9/21/2011

Miscellany (cont’d) Questions?

• What kind of libraries are there – Database driver (mysql, prostgresql,…) – Apache commons (algorithms, math, stats) • http://commons.apache.org/components.html

Michael V. Yudelson (C) 2010 17 Michael V. Yudelson (C) 2010 18

5