Lab 3 - Development Environment
During this lab you will finally work as developers (during previous labs you already have tried managers/system analysts roles). But in order to develop something you must first set up the development infrastructure.
Setting Up Development Environment
JAVA and Eclipse should already be quite familiar for you. During the next labs Eclipse becomes our main development tool. You will keep your code in the already well-known GitHub repository. The same environment where you published analysis documents produced during the previous labs.
Installation
Downloading and installing required components:
- JAVA 7.X (SE JDK) - http://www.oracle.com/technetwork/java/javase/downloads/index.html (JAVA_HOME)
- Eclipse Kepler. For labs it is enough to have just an Eclipse IDE for Java Developers - http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/keplerr
- Also do not forget to properly set the installed JDK as default JRE in Eclipse
- Window->Preferences->Java->Installed JREs->Add
- Standard VM
- select path to JDK like C:\Program Files\Java\jdk1.7.0_40
- Window->Preferences->Java->Installed JREs->Add
- Also do not forget to properly set the installed JDK as default JRE in Eclipse
- Windows users are installing also the following (other OS users figure it out themselves, during this course we extensively support only windows users):
- GIT for command prompt
- NB! Select Run Git from the Windows Command Prompt
- SourceTree - we recommend this classic tool, has a quite natively understandable GUI
- Also an Eclipse plugin EGit could be quite handy, try it out:http://www.eclipse.org/egit/ (can also be easily installed from the Eclipse Marketplace)
- GIT for command prompt
- Apache Ant: If you want to run ANT targets from the command prompt (in Eclipse it is provided by default) http://ant.apache.org/bindownload.cgi (PATH, ANT_HOME)
Empty Demo Application
(for your own examination - not for submission)
Before you start developing the current homework application we test everything with a demo application. Demo application shows how ANT and Log4J can be configured.
Make a project based on the given code and check which tools/techniques/technologies are used:
- Download the demo application source
- Import this project to the Eclipse and set up the build path properly if needed.
- Build and run your application with ANT targets
- Check console
What Components are Used?
- Apache Ant
- Apache Log4J
- JGoodies
So, who are they? What are they doing for us?
Familiarizing with the Application
- Build project with ANT (build.xml).
- Build project with Eclipse built-in compiler
- Check Log4J configuration (etc/log4j.xml). How current configuration is set now?
- Read JAVA code. What class is executed first? How logs are written? What class is responsible for showing the list of products?
Create a new JAVA project (if you did not do this during the lab then do it at home)
Use Eclipse to create a new JAVA project and name it "POS". Create two files there: application.properties, version.properties. So, the structure of your project would be:
Project
- application.properties
- version.properties
- plus folders created by Eclipse (src, ...)
Create a test repository and commit your project there. Check your project in the web, can you see your files online?
Git commit, GitHub
How it can be done with Eclipse plugin step-by-step:
Share the project:
- Eclipse -> Choose project -> right mouse click -> team -> share project
- Choose Git
- Create the repository locally, press finish
- Commit the code:
- Eclipse -> Choose project -> right mouse click -> team -> commit
- Check if all files are selected to be committed to the repository.
- Push your commit to the GitHub Server
- Eclipse -> Choose project -> right mouse click -> team -> remote -> Push..
- Set URI: https://github.com/[your account]/[your test repo name].git
- Set your GitHub username and password
- Select master branch
- Check if other team members can clone your repository in the Eclipse? Can they commit and push modifications to the code? (if not add them as collaborators for your test repository)
Find out how to perform the same operations in the SourceTree yourself (much easier)
Your Task (must be submitted)
Create a new Java project in Eclipse and name it "POS". Required structure of the project is following:
Project
- lib
- src
- build.xml
- application.properties
- version.properties
Project can have other additional folders and files. Create two new classes Intro and IntroUI. Classes must be in the package ee.ut.math.tvt.[my team name]
In the new class IntroUI you need to create an intro of your team. When class is intialized, it should open a window where must be the following information:
- Team name
- Team leader
- Team leader email
- Team members
- Team logo (random image)
- Your software version number
Class Intro is used as an ANT target and this class should run your IntroUI in the MAIN method.
Software version number should be read from the file version.properties. Version number should have format x.x.x and as a result your version.properties file must have:
- build.revision.number
- build.minor.number
- build.major.number
- build.number - in format x.x.x, consists of:
- build.major.number+.+build.minor.number+.+build.revision.number
Everything else (besides the version number), should be read from application.properties file.
In addition, you need to add corresponding message in the log that would indicate that intro window is opened. Use Log4J functionality for it. Log should have event time and name of the component (invocated class name)
Add required targets to the project ANT script. Ant build file must have the following targets:
- clean - removing the files created during the previous build
- build - compiling the source code and sets log4j and other files in the right places
- run - executes your application via class Intro
- dist- creates in the folder build/jar a separate JAR file, that has all your created classes, two property files and other components that are required for running your intro window. The name of the JAR file must be your team name. In addition, with every new JAR file build, your build.revision.number must increase automatically by one and as a result build.number last part must also increase by one.
- jrun - opens your intro window using the JAR file created by your dist ANT target
Your results must be submitted using your GitHub repository in the folder trunk. Additionally, create a tag with name homework_3 and as a comment you should write "Homework 3", so on the GitHub you will have:
- "https://github.com/[account name]/[repo name]/tree/homework_3"
Additional Links
- Log4j – http://logging.apache.org/log4j/1.2/manual.html
- Apache ANT - http://ant.apache.org/manual/index.html
- JGoodies - http://www.jgoodies.com/downloads/articles-and-presentations/
- Effective Eclipse: Shortcut keys - http://eclipse.dzone.com/news/effective-eclipse-shortcut-key
- Git Book: http://git-scm.com/book
Some Google Queries:
- ant compile
- ant create jar file
- ant write properties file
- jgoodies examples
- How to use Git with Eclipse
- git command line
- jpanel add image
- git tagging