Category Archives: Eclipse

A blog about things 2014-03-10 14:03:00

Since my last Blog I have done a lot of work to get my workspace up and running. I first had to download and install java EE version of Eclipse from http://www.eclipse.org/downloads/

Once I had the EE version of eclipse i set out to make sure that EGit was installed and configured. It was already installed out of the box. So I cloned my project and then imported it into eclipse as a maven project. All this was done by following these instructions
Once that project was in my eclipse I built it by right clicking on the project -> Run As->Maven Clean. Then right clicking on the project -> Run As->Maven install. 
This kicks out a open.war to webapps/target folder. Then I deploy the openmrs.war to webapps folder in tomcat and am able to access the site via localhost:8080/openmrs. 

From the blog A blog about things by TRStaake and used with permission of the author. All other rights reserved by the author.

Setting up your development environment

This is a guide for creating a new Android Eclipse project from source code on GitHub. It is tailored to my independent study project for the benefit of my partners, but it could be easily adapted to any Android project.

Note: This guide was created for Windows 7 64-bit. Other versions of Windows should be similar.

1. Download and install Java SE Development Kit for Windows x86

Note: I highly recommend NOT installing to the default C:\Program Files (x86)\Java\ folder. The Program Files folder has very restrictive permissions which may cause file writing/copying errors in the future. I chose to install to C:\Java\.

2. Download and install Android SDK for Windows

Note: Again I recommend NOT installing to the default folder. I chose to install to C:\Android\.

3. Run the Android SDK Manager and install the groups: Tools, Android 4.1 (API 16), and Android 2.2 (API 8).

4. Download either Eclipse Classic for Windows 32-bit or Eclipse for Java Developers for Windows 32-bit

5. Extract the downloaded eclipse\ folder into your Java\jdk*\ folder

6. Download and install GitHub for Windows

7. Run Eclipse, and choose your GitHub folder as your workspace

8. Install Eclipse ADT Plugin

Note: If you get an error after restarting Eclipse about not being able to find the Android SDK, just click the Preferences button and point to your Android\android-sdk\ folder.

9. Create a new Android project, and then close Eclipse afterwards

Name the project Task Butler, and name the package edu.worcester.cs499summer2012. The target SDK should be API 16 and the minimum required SDK should be API 8.

10. Clone the CS499Summer2012 repo to your local GitHub folder

11. Move the local repo files into your Task Butler folder

  • In your GitHub\Task Butler\ folder, delete everything EXCEPT .settings\, .project, and .classpath
  • Move everything from GitHub\CS499Summer2012\ into GitHub\Task Butler\
  • Note: Make sure “Show hidden files, folders, and drives” is enabled in Windows Explorer’s Folder options so you can see the hidden .git folder
  • Delete the now-empty \GitHub\CS499Summer2012\ folder

12. Reopen Eclipse, and the project should now have all of its files (and lots of errors!)

13. Download ActionBarSherlock and extract it somewhere

I chose C:\Android\

14. In Eclipse, import the library\ folder inside the ActionBarSherlock folder as a new project

15. Modify the library’s Android properties and Java Compiler properties to get rid of errors

Make sure the build target is set to 4.1 and the “Is library” checkbox is checked.

Make sure the Compiler compliance level is set to 1.6.

16. Modify Task Butler’s Android properties to include the new library

Make sure the build target is 4.1 and add ActionBarSherlock to Library (if there is one listed already with a question mark, remove it).

17. If necessary, clean the project and it should rebuild itself with no errors.

The project is now ready to be worked on!

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

A quick note on Jelly Bean

With the release of the Android 4.1 Jelly Bean SDK, our project will now have a build target of 4.1 Jelly Bean and a minimum required version of 2.2 Froyo. Also, a lot of the problems experienced in my post about setting up the SDK have disappeared. The AVD location bug is gone, and the Eclipse ADT Plugin installs just fine from the online repository. It’s nice when things work!

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

The trickiness of using Git in an Eclipse project workspace

I know there is a Git plugin for Eclipse, but I prefer to do things the old school way with terminal commands. So when it came time to make sure my Eclipse project folder was being tracked by our remote repository on Github, I thought I could just clone our repository and then create a new Eclipse project in that same directory. Except Eclipse does not let you create a new project in a directory that already exists. And I wasn’t going to try to clone into a directory after it had already been populated by local Eclipse files; who knows what kind of problems that would have created.

If there is an elegant solution to this problem, I didn’t find it. I changed the name of the cloned directory, then created my Eclipse project using the original directory name now that it was unused and available. Then I moved all the Git files into the new directory, and deleted the now-empty one with the changed name. And everything works great.

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

Setting up the Android SDK & Eclipse

This summer I will be developing an Android app with James, who is also a senior CS major at Worcester State. Neither of us have ever done anything like this, so needless to say it will be an adventure. The first thing I had to do was to properly set up my development environment. Google has a guide here, but it wasn’t the smoothest process. There was a bit of trial and error along the way. I have a fairly modern computer running Windows 7 64-bit. Here’s my rundown of setting everything up:

Step one was to install the JDK, Java Development Kit. That was easy enough. Oracle’s website has lots of options, so it was important to choose the standard 32-bit JDK installer. Even though I have a 64-bit system, I chose 32-bit in order to maximize compatibility.

Step two was to install the Android SDK. Once that has been installed, running the SDK Manager lets you choose what Android platforms to download. For now, I only downloaded the latest version, 4.0.3/API15.

Next was to install Eclipse. Eclipse.org has a lot of options. I opted for Eclipse for Java Developers 32-bit (matching my 32-bit JDK), though I hear Eclipse Classic works too. There is no installer exe for Eclipse, only a zip file, which might confuse Windows users. You just need to extract the zip file into your JDK directory, and that’s it. In my case, Eclipse ended up in “C:\Program Files (x86)\Java\jdk1.7.0_04\eclipse”. Then you run eclipse.exe from that folder and off you go.

Inside Eclipse, the next step is to install the ADT plugin, which will integrate several Android tools into Eclipse. This is where things started getting a little hairy. According to the Google guide, Eclipse should be able to grab the tools from a repository located here: “https://dl-ssl.google.com/android/eclipse/”. Eclipse did that, then proceeded to tell me that the tools couldn’t be installed. After a lot of searching, I didn’t find a fix, but I learned the problem possibly has to do with the fact that I am using a newer version of Eclipse (Indigo) than when the guide was written (Helios). Thankfully, Google offers a manual download of the tools here, so I was finally able to get the ADT plugin up and running.

Now that the Android SDK and Eclipse were both configured, it was time to write a program! The Google guide has a very nice-looking series of tutorials, starting with a Hello World app. The first thing to do was to make an AVD (Android Virtual Device), an Android phone emulator. This went smoothly. So did creating the new project, and writing up the simple code. Now to run my very first Android program…

FAIL. In the console, in bright red, I see the message “PANIC: Could not open: C:\Users\Jon\.android/avd/my_avd.ini”. What is this?? Why can’t it find my emulator??? I check, and sure enough, there is no .android folder in my Jon directory. The .android folder is on the root of my D:\ drive, and the AVD is in there. So why is Eclipse looking in my user folder, and how can I fix it? After a lot of searching, I found my answers here. It turns out that this is an ADT bug, and to fix it, I had to make a symbolic link between the two locations. So, in a Windows command prompt, I ran:

mklink /J “C:\Users\Jon\.android” “D:\.android”

An .android folder showed up inside my user directory, identical to the one in D:\. It’s important to note that if I ever want to delete this link, I need to run rmdir rather than just delete the folder. Otherwise, Windows will delete both locations instead of just the symbolic link. I went back to Eclipse and tried running my program again, and it worked! I’ve never been so happy to see “Hello World” appear on my screen.

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.