Eclipse

July 16, 2010

I’m sure that you have heard of Eclise.  If not then all you need to know is that it is a very popular (and for a good reason) IDE mainly for Java.  However, it does also have C/C++ support, but it is mostly used with Java.

As you know, I’m not big on programming in Java.  But I recently purchased a Nexus One phone, and the IEEE SECon got me a little interested in Android application development.  I don’t plan for anything I make to be widely distributed, but rather just for personal use.  In any case, I would still need a place to create my programs.  Sure this can be done with a normal text editor and the command line but why bother with that when Eclipse and the Android SDK make it so simple?

I’m going to talk about getting and installing Eclipse onto you system (which I will assume to be Ubuntu).  Sure you could just run sudo apt-get install eclipse but this way assumes that you are using the OpenJDK version of Java and not Sun’s. So if you are using SunJava, which it seems most people do, then this how-to is for you.

First head over to the Eclipse site and download the IDE. To find the site just use Google and then do some reading and clicking, so there is no need for me to post a link. If you can’t get past this step then you probably shouldn’t be thinking about using Eclipse.

Next we will open the package you have just downloaded and then move it to the /opt directory. To do this just run the following sequence of commands:

tar xzf <filename>
sudo mv eclipse /opt/eclipse
cd /opt
sudo chown -R root:root eclipse
sudo chmod -R +r eclipse
sudo chmod +x `sudo find eclipse -type d`

The chown command changes the owner of a file/directory, if you have been reading this blog then you should be able to figure out what the other commands do.

Next we will add eclipse executable to your path.

sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse
sudoedit /usr/bin/eclipse

then add this to the file

#!/bin/sh
#export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"
export ECLIPSE_HOME="/opt/eclipse"

$ECLIPSE_HOME/eclipse $*

I’m not all to sure exactly what the touch command does but you can look that up yourself (either online or with man).

Finally, the “most important” part; creating a GNOME-menu icon. This is something that would normally be done when you use the apt-get method.


cd /usr/share/applications
sudo nano eclipse.desktop

And enter the following into the created file;

[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true

All the stuff entered into the file makes perfect sense, so if you ever wanted to make a menu item for any other program you now know how.

All of these steps can be found at http://flurdy.com/docs/eclipse/install.html.


Acrobat Reader

March 25, 2010

Well long (though interesting) story short I had to reinstall Ubuntu (still version 8.04).  I’ll give you th long story soon enough, but first here is something that might be useful.

At first I was fine with using Evince for viewing PDF files but there are just a few things that Acrobat does that I like.  Overall I still prefer Evince since it is much faster at loading and not “bloated” with features that I won’t ever use.  Regardless I still needed to install Acrobat.

Normally you would be able to just run sudo apt-get install acroread, but for some reason acroread is no longer in the Ubuntu list of provided programs.  So I had to do some work on Google.  Sure finding Acrobat was easy but I needed to make sure that it would work on an 64bit OS.  As usual, a pain in the ass.

I won’t go into all that I tried, I’ll just tell you what worked.  First go to this site http://get.adobe.com/reader/ and choose the appropriate OS (Linux) and the .bin file.  Apparently choosing the x86 version is fine.  Assuming that it was downloaded to your desktop run chmod u+x *.bin, where * is whatever the file is called.  Then finally run sudo ./*.bin.  Make sure to add the sudo or you’ll run into some issues (I’ll let you see what kind).  During the install when asked where to store the file(s) make sure to pick a location that is in your PATH.  I chose /usr/bin but I suppose that any location will work.

Now you can run acroread and be on your way.


Change Mode

August 16, 2009

So you have written your first program in Perl and it probably looks something like this


#!/usr/local/bin/perl

# We will call the program hello_world
print “Hello world\n”

Now you try to run it with the command ./hello_world, only to find that it won’t run.  Well the reason is obvious, well to experienced users anyway.  The problem is that your program doesn’t have permission to be executed.  Instead you first need to run chmod u+x hello_world, then ./hello_world will run as expected.
The function of the chmod command is to change the mode of a files.  The modes are permissions and special modes.  I will only touch on permissions in this post.  The format for this command is as follows

chmod [references] [operator] [modes] file1...

references: who you want to apply the changes to
operator: how the changes are to be made
modes: which changes are to be made

The references are; u, o, g, and a u is the owner of the file.  g is users who are members of the file’s group.  o is outsider, members who are not specified by either u or g.  Finally a is all, this is equivalent to uog.

The operators are; +, , and =.  As can be expected you use + to add permissions and to remove them.  The = is a little harder to explain but is made perfectly clear with an example (which is later in this post).

The modes are; r, w, x.  They stand for read, write, and executable respectively.

Well now I suppose you would like to see some examples of this in use.  For all these examples we will assume that hello_world has the following initial modes: -rwxr-xr-x, this means that the owner (the first grouping of rwx) has the ability to read, write, and execute.  However, group members (the second grouping) and outsiders (the last grouping) can only read and execute

Example 1: Make it so that the owner only has executable permission.  After using the following command, the file’s modes will look like —xr-xr-x

chmod u=x hello_world

Example 2: Make is so that the owner can only read and execute.  After using the following command, the file’s modes will look like -r-xr-xr-x

chmod u-w hello_world

Example 3: Make it so that group users and outsiders  can read and write only. While not affecting the owner’s permissions.  After using the following command the file’s modes will look like -rwxrw-rw-

chmod og=rw hello_world

Example 4: Make it so that no one has execute ability.  The file’s modes will look like -rw-r–r– after using the following command.

chmod a-x hello_world

Example 5: Make is so that people that aren’t group members or the owner have write permission.  The file’s modes will look like -rwxr-xrwx after using the following command.

chmod o+w hello_world

So that wasn’t too bad, and hopefully you noticed how the = operator works.  Finally, it is worth mentioning that in order to see a file’s modes you only need to use ls -l file.  For more information on chmod check out this Wikipedia entry, and for examples follow this link.