The Coded One

programming, algorithms, discrete math, open-source

Posts Tagged ‘Linux

Setting Up Tomcat on Ubuntu

with one comment

Prerequisites

Tomcat 6.0 requires JRE 5.0. Read the RELEASE-NOTES and the RUNNING.txt file in the distribution for more details.

Installation

1. Download binary core from apache site.

wget http://apache.tradebit.com/pub/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz

2. Extract the tarball under /usr/local/

Note: Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.

tar xvzf apache-tomcat-6.0.18.tar.gz

3. Tomcat requires that you set the JAVA_HOME variable. If you haven’t done it yet, you can do so by adding the following line in your .bashrc

export JAVA_HOME=/usr/lib/jvm/java-6-sun

4. We can test if Tomcat is running by running the startup script then opening a browser and accessing http://localhost:8080

sudo /usr/local/tomcat/bin/startup.sh

Details on troubleshooting can be found on RUNNING.txt

Read the rest of this entry »

Written by Mark Basmayor

March 2, 2009 at 5:37 pm

Posted in Java, Ubuntu

Tagged with , , , ,

Setting Up MySQL/JDBC Driver on Ubuntu

with 5 comments

Assuming that you already have MySQL installed, the next step is to install the connector driver. You can do this easily on the CLI by using the following command:

sudo apt-get install libmysql-java

The next step is to make sure that the classpath is set. You can have this set automatically by adding this command to you bashrc file.

export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar

If you want to set this for all users, you should modify the /etc/environment instead.

For those using Eclipse, you can also do this by going through the following steps:

  1. Select Project Properties > Java Build Path
  2. Select Libries tab
  3. Click Add External Jars
  4. Choose the jar file, in this case mysql-connector-java.java

Once you’re done, you can test the connection using the following snippet:

import java.sql.Connection;
import java.sql.DriverManager;

class JDBCTest {

	private static final String url = "jdbc:mysql://localhost";

	private static final String user = "username";

	private static final String password = "password";

	public static void main(String args[]) {
		try {
			Connection con = DriverManager.getConnection(url, user, password);
			System.out.println("Success");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Written by Mark Basmayor

March 1, 2009 at 1:32 pm

Posted in Java, Ubuntu

Tagged with , , , ,

Developing with VIM

leave a comment »

VIM or Vi Improved is a text editor that is very popular among programmers especially those working in *nix environments.  It was originally released by Bram Moolenar in 1991 for the Amiga computer.  http://en.wikipedia.org/wiki/Vim

I have to admit that when I first used VIM, I was very skeptical.  I thought that it was “just another text editor” like nano or pico.  But since I’ve been hearing lots of good things about it, I finally decided to give it a shot.

vim screenshot

I wasn’t immediately converted as a vim user.  I’m used to IDEs like Eclipse and NetBeans.  I was missing lots of things like code completion, folding, automatic formatting, etc not to mention the fact that it was completely a different environment (modal).

But eventually I got comfortable and started having fun with it.  And now with VIM 7 I can do everything that I’ve been missing.  It’s got a legitimate syntax highlighting, code completion, auto formatting, etc.  And you can continue to buff it with plugins and a decent vimrc.  Here’s the one that I compiled based on some of the best vimrcs that I saw.

Some of the reasons why I prefer using it over an IDE are:

  1. It’s lightweight.  It’s blazing fast compared to launching Eclipse.  This comes very handy when you only need to write/edit several lines of code.
  2. You can use it over SSH.  If there’s a file that you need to open/modify on the fly on a remote location, this is just the way to go.  I mean who would like to download, modify, re-upload?
  3. The transition is seamless when in a terminal.  There’s just no better tool for editing config files/scripts.  Also, FYI the bash shell uses VIM mode by default.
  4. You can search/replace using regular expressions.  This feature is one of the reasons why I kept going despite the steep learning curve.
  5. Finally I just don’t see any limit to its capabilities since you can always add custom scripts and install plugins.  Btw, there are over 2,000 plugins that you can choose from in the plugins section of vim’s website.

Written by Mark Basmayor

February 26, 2009 at 3:37 pm

Posted in Linux, Ubuntu

Tagged with , ,

Removing Trailing Spaces in VIM

with 2 comments

We all hate trailing spaces when programming, so here’s something that will rid us of that forever.

Before quitting, execute this simple find and replace command in VIM.

:%s/s+$//

What this does is it looks for one or many instances of space (s) just before the end of line ($) and replaces it with a null string.

Even better, you can have this command execute every time you save by binding this to the save command in your .vimrc (vim configuration file).

autocmd BufWritePre * :%s/s+$//e

Written by Mark Basmayor

August 22, 2008 at 2:14 am

Posted in Linux, Ubuntu

Tagged with , ,

Introduction to SVN

leave a comment »

What is SVN?

Subversion (SVN) is an open source code manager and version control system intended to replace CVS.  It is a system that manages files and directories, and the changes made to them over time.

Why use SVN?

SVN is great because

  • it remembers all the changes written to it: create, edit, update files/directories
  • it saves previous states, not just the current, so we can restore from a given date/version/etc
  • prevents concurrence issues like overwriting someone else’s work

Read the rest of this entry »

Written by Mark Basmayor

April 11, 2008 at 5:06 am

Handy Shell Commands

with 2 comments

shell

The Linux shell or sometimes called the command line or terminal is a text-based interface to the kernel. With the rise of GUI tools, some would think that there is no longer a need for this. But still, I am yet to find a GUI tool that can even compare with the simplicity, efficiency and power of the shell. For those who are new, here’s a list of commands that you might find helpful. Enjoy!

Read the rest of this entry »

Written by Mark Basmayor

April 6, 2008 at 9:15 pm

Posted in Linux, Ubuntu

Tagged with , , , ,

Follow

Get every new post delivered to your Inbox.