Updating Eclipse to use a specific Java Runtime Environment (JRE) by default

Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!

Prerequisites

Problem

You installed a JRE on your operating system but your Eclipse IDE doesn’t seem to see it.

Solution

  1. Open Eclipse
  2. Select Windows -> Preferences -> Java -> Installed JREs
  3. Select the Add button -> StandardVM -> select the Directory button (next to JRE home)
  4. Select the path where the target JRE folder is located (e.g. C:\Program Files\Java\jre7) and hit OK.
  5. Select the checkbox next to the new JRE
  6. Still in the preferences dialog, select Java -> Installed JREs -> Execution Environments
  7. Select all environments and put a check next to all environments that can use the newly installed JRE
  8. Select Java -> Compiler -> Compiler Compliance Level -> Select the JRE you just installed
  9. Select Java -> Compiler -> Compiler Compliance Level -> De-select Use Default Compliance Settings
  10.  On the same screen, next to Generated .class files Compatibility, select the newly installed JRE from the dropdown
  11. On the same screen, next to Source Compatibility, select the newly installed JRE from the dropdown
  12. Select OK in the Preferences Dialog and your done.
Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!

Advertisements

Installing Java Runtime Environment 1.7 (JRE1.7)

Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!

Problem

You need to install a Java Runtime Environment (JRE) but don’t know where to start.

Solution

Installation is fairly simple once you find the desired version’s web address.

  1. Go to http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html
  2. Scroll down the page and locate your operating system
  3. Click the Accept License Agreement radial button
  4. Click the download link to the right of your operating system
  5. Save the file and allow it to install.

If you are using Windows x64 default settings the files should be located at C:\Program Files\Java\jre7

Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!

Debugging Android Project DDMS Heap Dump in Eclipse

Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!

First off, what is a heap dump? A heap dump is essentially a snapshot of an application’s data at a given point in time.  It maps a specific process, view, etc. to the memory being used.  Sort of like ctl-alt-delete on windows in order to determine what’s using up your app’s memory.

To get a heap dump in Eclipse for an application running on your device:

  1. Open Eclipse
  2. Run the target application on the target device by pushing the application to the device over USB (then keep USB connected).
  3. Select Window->Open Perspective->DDMS
  4. The target device should be shown on the left side in the devices window.
  5. The target application should be shown under the device
  6. Select the target application and then the Dump HPROF file icon(half-full glass with green fluid and red arrow). This will prompt you to save the file; do so.

Convert Android HPROF to readable HPROF

  1. The previous file cannot yet be read by the Eclipse MAT tool (see below) and so must be converted first.
  2. On your computer go to C:\…\android-sdks\tools (where … is wherever you installed eclipse) and copy the hprof-conv.exe file
  3. Navigate to the folder where you saved the heap dump and paste the hprof-conv.exe file (you can probably keep it in its original location and navigate to files, but I’m lazy).
  4. Open a command prompt and navigate to the folder where your file and the hprof-conv.exe file are located (can do using cd:\folderName).
  5. Type the following line into the command prompt and hit enter:

hprof-conv dump.hprof converted-dump.hprof

Your newly converted file will be created in the same folder as the original file and will be called converted-dump.hprof.

Opening HPROF in Eclipse after conversion:

  1. Go to Window->Open Perspective->Other->Memory Analysis
  2. This may take a while to open
  3. When it opens, it will show up amoung the coding windows-at least mine did-and so find it using the window icon that looks like a disk structure
  4. From here, you will be at the home screen of MAT with your app’s dump file.  Use any of the following links as reference on how to analyze things:

NOTE: READ THIS…I was trying to open the converted file in Eclipse since I had the MAT plug-in installed and everything went well.  But, that was only because I recorded the HPROF before installing the MAT plug-in for Eclipse.  After I installed that plug-in, DDMS stopped asking me where to store my file and what to name it.  This became very frustrating since I couldn’t get dump files, but I noticed that randomly numbered tabs were showing up in the java perspective and had the MAT disk icons.  Well…blam! Those were the dumps and already converted for me.  Also, if I hit the phone icon in DDMS it will do a screen capture dump showing me layout views and images on screen! Awesome!!!!

Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!

Eclipse GitHub Push Error: master:master [rejected – non-fast-forward]

Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!

So, you’ve run into the following VERY annoying message:

master:master [rejected – non-fast-forward]

If you are a nube to Git, which I certainly am, you have no clue what this means, why it’s happening, or how to fix it.  Also, if you’ve traveled down the same path I have, then you’ve encountered this message after one of the following scenarios:

  1. Used EGit in Eclipse to connect a local repository to an already created repository on GitHub.  After setting correct SSH and then trying to push, you get said message.
  2. Local repository has been pushing to remote repository on GitHub forever and randomly crapped out with the message.

If so, then the problem is most likely that your local and remote repositories are out of sync, and there’s a conflict between some files.  Follow the procedure below to resolve this problem.

  1. First, make sure the most recent changes have been committed. To do this, in Eclipse, right-click on the application’s folder->Team->Commit.  If a pop-up does not say “Up-to-date”, then finish committing the current changes to the local repository.  If it’s already up-to-date, continue.
  2. Try to pull from the remote repository to the local repository; then push to it. To do this, in Eclipse, right-click on the application’s folder->Team->Fetch From Upstream.  If you were able to pull, then push by right-click on the application’s folder->Team->Fetch From Upstream. If unable to pull because of an error, then continue.
  3. At this point, I had to force a push from my local repository to remote repository on Github.  Forcing a push will override any changes on Github with the changes from your local repository! If this is not your goal, DON’T CONTINUE. If it is your goal then do the following:
  • Right-click on application’s Folder->Team->Remote->Configure Push To Upstream
  • Configuration dialog will pop-up->Under “Ref mapping” hit “Advanced” button
  • Push Ref Specifications will pop-up->Select “master [branch]” under “Source Ref” and “Destination Ref”
  • In same window select “add spec”
  • You should now see this update in the “Specifications for push” window; select “Force Push” next to it
  • Select “Finish”

At this point my problem was fixed, but I also didn’t care about throwing  away changes on GitHub.  If you are concerned about this, please keep Googleing because I don’t know how to fix it.

Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!

Connect Eclipse Repository to GitHub using EGit

Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!

I assume that if you’re reading this, you know something about the content/document management system called git. Hopefully you understand what a repository is and how to push from a local repository to a remote one, and then pull from the remote repository to the local one.  If not, read about git here.

Also, I’m assuming that you know what Eclipse is and have installed Egit.  If not, read the EGit installation tutorial here.

So, you know what git is and have used EGit a little, but what is Github? Github is a website that allows its users to create remote repositories that are shared with everybody on GitHub – unless the user purchases a private repository.  Users who are added as collaborators can pull the code from the remote repository on Github to a local repository on their machine, modify it, and then push the updated code back to the repository on Github.  Non-collaborators cannot push changes but they can pull code to a local repository on their own machine and use it as they wish.

The following procedure explains how to use Egit from within Eclipse to create a repository on your local machine for storing and managing an application’s files and their history.  It then explains how to connect the local repository to a remote repository on Github so that other users can access it.  This procedure is the same as described in this YouTube video, but clarifies some confusing steps that are essential to this working.

1. Open Eclipse

2. Create  the “Hello World!” application as explained here.

3. Right-click on the “Hello World” folder in the Package Explorer Window

4. Select Team->Share Project

EclipseGithub

5. In the pop-up window select “Git” then “Next”

EclipseGithub2

6. In the Configure Git Repository window select “Create” next to the Repository dropdown menu.

EclipseGithub3

7. In the Create a New Git Repository window type the parent directory and the name of the folder you’d like.  Both of these are the user’s choice. Select Finish

EclipseGithub4

8. Select “Finish” in the Configure Git Repository window to create the repository in the selected folder.  This will delete the project from the workspace folder and put all of the files in the new repository.

EclipseGithub5

9. There will be a red exclamation mark over the “Hello World” folder in Eclipse with the note [Hello World NO-HEAD].  This is because the repository is empty until the first commit.  To commit the project files to the repository for the first time.  So, commit the files for the first time by right-clicking on the application’s folder->select Team->Commit.

EclipseGithub6EclipseGithub7

10.  In the Commit Pop-up window say “First commit” (or whatever you want) and select all files-my personal preference but you can select what files to commit.

EclipseGithub8

11. There may still be a problem.  If so, right-click on the application’s folder and select “Close Project”.

EclipseGithub11

12. Reopen the project by right-clicking on the application’s project and selecting “Open Project”.

13. Select Project in the Eclipse menu, then “Clean Project”.  Select the application’s folder and hit “OK”.  The errors should be gone.

EclipseGithub12

14. The project is now using the local repository to store its files and is able to track changes-though the user must commit in order for changes to be saved to the repository.

15. In order to synchronize the local repository to Github, you need to generate an SSH key. In the Eclipse menu select Window->Preferences->General->Network Connections->SSH2.  Then select the “Key Management” tab and click the “Generate DSA Key”.  This will populate a key in the window below the buttons.  If you can’t see it, expand the window-mine was gone until I maximized the window.  Copy this key into the clipboard.  Select “Save Private Key”, select the destination folder (I used the default folder) and select “OK”.

EclipseGithub14

EclipseGithub15

EclipseGithub16

16. Go to Github.com and sign into your account.  If you have not created an account, do so now.

17. Select the “Add New Repository” button at the top right of the screen.

18. Type in “Hello World” as the new repository name and make it “Public”-unless you would like to pay for it, then you can make it private. Then select “Create Repository”.

EclipseGithub17

19. The new repository has been created and the path for it is listed under the header “Quick Setup.”  Select the “copy to clipboard” icon to the right of the repository path name-and don’t copy anything else to the clipboard!

EclipseGithub18

20. Go back to Eclipse and open the Repository Browser by selecting Window->Show View ->Git Repositories

EclipseGithub13

21. In the Repository Browser expand “Hello World”, right-click on “Remotes”, and select “Create Remote”.

EclipseGithub19

22. Call your new remote “origin”, select “Configure Push” and hit “OK”.

EclipseGithub20

23. In the “Configure Push Window” select “Change” under URI.  This will open the “Destination Git Repository” window.

EclipseGithub21

24. In this window you should automatically see the new repository information populated.  If not, it’s because you copied something else to your clipboard, so close the window and copy the repository link from Github again. Select “SSH” under “Protocol” and select “OK”.

EclipseGithub22

25. The “Hello World” app should now be pushed to Github and you should be connected.

NOTE: If the pushed failed due to:

master:master [rejected – non-fast-forward]

Then see my post on fixing this issue.

Helpful? Then DOWNLOAD and RATE my app!

Helpful? Then DOWNLOAD and RATE my app!