Development

From TechWiki

Contents

Java

Finally, there is a sun java 5 package for ubuntu:

apt-get install sun-java5-jdk

Voila!

The voodoo you used to have to know:

download binary (e.g., JRE 5.0 Update 7: jdk-1_5_0_07-linux-i586.bin) from http://java.sun.com/j2se/1.5.0/download.jsp
apt-get install fakeroot java-package java-common
fakeroot make-jpkg jdk-1_5_0_07-linux-i586.bin
dpkg -i sun-j2sdk1.5_1.5.0+update07_i386.deb

This installs. Now you have to tell the system to use thi right version:

update-alternatives --config java

The Old Way

1.4

For Debian GNU/Linux.

Download newest JDK from Blackdown.org, e.g.:

ftp://mirror.switch.ch/mirror/java-linux/JDK-1.4.2/i386/01/

Execute these terminal commands:

cd /usr/local
sudo sh ./j2sdk-1.4.2-01-linux-i586.bin
sudo chown -R root:src j2sdk1.4.2/

And set some (bash) environment stuff (see also here):

export JAVA_HOME="/usr/local/j2sdk1.4.2"
export JDK_HOME="${JAVA_HOME}"
export PATH="${JAVA_HOME}/bin:${PATH}"

5

At the time of writing (4th of March 2005) Java 5 (i.e., 1.5) is still only available from sun:

http://java.sun.com/j2se/1.5.0/download.jsp

Download Linux self-extracting JDK or JRE, e.g., jdk-1_5_0_04-linux-i586.bin. Unzip with

sh jdk-1_5_0_04-linux-i586.bin

Java 5 features.

Useful jars

Eclipse IDE

Eclipse is a really cool, powerful open source IDE for Java und much, much more.

More on using it in EclipseStuff.

Install - New

Using kubuntu (Breezy).

The easy way:

apt-get install eclipse-sdk

Install - Old

Using Xandros; this was the old and hard way...

Download eclipse-SDK-3.0.1-linux-gtk.zip from Eclipse.org, e.g.:

http://mirror.switch.ch/mirror/eclipse/downloads/

or newer:

eclipse-SDK-3.1M5a-linux-gtk.tar.gz

Unzip in:

/usr/local/eclipse

Place wrapper script called eclipse in /usr/local/bin:

#!/bin/sh

######################################################################
#
# This is a wrapper script to start up the Eclipse IDE
#
######################################################################
#
# It is expected to be installed at:
# /usr/local/bin
#
# This script expect to be run as: "eclipse" or "eclipse3.1"...
# There is only one script "eclipse" then the versionned scripts are
# just symlinks to it.
#
# It expects to find eclipse in (for example for linux):
#     /usr/local/eclipse
# and JDK in:
#     /usr/local/1.4.2
#
# You have the responsability to make the symlinks between the "1.4.2"
# and the real directory where the JDK is for this distribution
#
######################################################################

PLATFORM=`uname | tr '[A-Z]' '[a-z]'`
ECLIPSE=`basename $0`
BASEDIR=/usr/local/
E_INSTALL=$BASEDIR/$PLATFORM/$ECLIPSE
JDK=1.4.2

# if JAVA_HOME is defined and valid, let's use it
if [ ! -d "$JAVA_HOME" ]; then

   # if not, here is a set of predefined versions
   case "$ECLIPSE" in

   'eclipse3.1')
       JDK=1.5.0
       ;;
   'eclipse3.1M5a')
       JDK=1.5.0
       ;;

   esac
fi

# if the executable is there, run it
if [ -x "$E_INSTALL/eclipse" ]; then
   export JAVA_HOME
   case "$ECLIPSE" in
   'eclipse3.1M5a')
       echo Running Eclipse 3.1M5a
       $E_INSTALL/eclipse -vm $BASEDIR/$PLATFORM/1.5.0/bin/java
   ;;

   *) $E_INSTALL/eclipse -install $E_INSTALL -vm $BASEDIR/$PLATFORM/$JDK/bin/java -data @user.home $@
   ;;
   esac
else
   echo "Error, it seems that $0 is not installed for $PLATFORM"
   echo "(missing file: $E_INSTALL/$ECLIPSE)"
   exit 1
fi

or simple wrapper:

#!/bin/sh

E_INSTALL=/usr/local/eclipse3.1

${E_INSTALL}/eclipse -install ${E_INSTALL} -vm /usr/local/jdk1.5.0_04/bin/java -data @user.home $1 $2 $3 $4 $5 $6

Java 1.4 and 5

Note that only Eclipse 3.1 supports Java 5 syntax. However, it does not require a Java 5 Runtime environment (jre5) to run. So the Blackdown's Java 1.4.2 is still fine to run.

In order to run Java 5 code we must tell Eclipse to use a different JRE. Go to:

Window->Preferences-> Java-> Installed JREs

and in the right pane select:

Add...

Now select the path where the jre5 is installed and set it as the default.

Run As Desktop Application

Execution command:

export PATH="../jdk1.5.0_01/bin:.:~/bin:/usr/local/bin:/usr/ccs/bin:/usr/bin:/bin:\
/usr/ucb:/usr/sbin:/usr/X11R6/bin/"; eclipse -data /home/jbg/work/new/ -Xmx512

Plugins

Usual way to tell Eclipse about newly downloaded plugins:

Help -> Software Updates -> Manage Configuration -> Add an Extension Location -> Select your plugin directory

PHP

PHPEclipse Manual.

Automated

  • Click on Help->Software Updates->Find/Install from file menu in Eclipse.
  • Select the radio button labeled, "search for new features to install".
  • Click on the "New Remote Site" button.
  • Enter a name, and the URL: http://phpeclipse.sourceforge.net/update/cvs (unstable) or http://phpeclipse.sourceforge.net/update/releases/ (stable)
  • Click on "Finish".
  • A list of features will be presented, open the list and check the one labeled "phpeclipse".
  • Click on "Next"
  • Follow the onscreen instructions to finish the automatic install.

Taken from plog4u.org.

Manual

Download zip-file from PHPEclipse.

Unzip in some directory. Copy plugin files to your Eclipse directory, e.g.:

/usr/local/eclipse3.1M5a/plugins/

and copy features files, e.g.:

/usr/local/eclipse3.1M5a/features

Run Eclipse and check that there are new Apache and MySQL buttons, and that under Windows -> Preferences there is PHPEclipse stuff.

Edit Apache.

More details:

Install PHP Parser

Check /usr/bin/php4, or get apt-get install php-cli. Set path in Eclipse (Window -> Preference -> PHPEclipse)

Install DBG

Download dbg-2.11.32-glibc-2.2-php43.tar.gz from here.

Untar in /etc/php4/extensions/.

Add in /etc/php4/apache2/php.ini:

extension=dbg.so

and at the end of the file:

[debugger]
debugger.enabled = true;
debugger.profiler_enabled = true;
debugger.JIT_host = clienthost;
debugger.JIT_port = 7869

Goto /usr/lib/php4/20020429 and:

ln -s /etc/php4/extensions/i686/dbg.so-4.3.9 dbg.so

Restart Apache and run php file with phpinfo(). Should show dbg info.

More: here and here.

Problems

To be able to run a php script, i.e., have the option Run -> Run... visible, a dummy Java project with a class needed to be created.

Subversion

The Subclipse plugin can be used to integrate Subversion into Eclipse. More on subversion here.

To install, go to:

Help -> Software Updates -> Find and Install... ->  Search for new features to install

Then select New Remote Site... and set a name and

http://subclipse.tigris.org/update_1.0.x/

as URL and click Finish.

Then select the name you just gave the feature and select Next and an install directory on your local file system.

Don't forget to add the new perspectives in the Eclipse workbench (see add symbol on to right corner) and add

SVN Repository Exploring
Team Synchronizing
Subversion Checkout in Eclipse

Problems checking out projects from the SVN repository in Eclipse 3.3.0:

Projects are not checked out as packages, e.g., ch.mysite.App.java is
put in the directory ch/mySite with all kind of strange problems
(no build path, not launchable)

Fixed it by selecting the following in the checkout window:

  • SVN Repository Exploring
  • Check out as a project configuration using the New Project Wizard
  • Java Project
  • Use project folder as root for source and class files
  • Confirm Overwrite dialog

SWT

SWT is Eclipse's answer to AWT and SWING.

Get jar:

Tutorial:

Eclipse settings:

  • -Djava.library.path=/usr/local/.../swt/swt3.1M6/linux_gtk

UML

jlint

Profiler

CAP


CDT

C/C++ development tools:

Help -> Software Updates -> Find and Install... -> Search for new features to install

select

Callisto Discovery Site -> CDT

Don't forget to build\compile after any code change, this is not Java;-)

Note that if you want to debug, you need to compile with the right option. For g++ it's -g, i.e., in you Makefile

g++ [...] -g [...] myCode.cpp [...]

gdb is the default debugger.

Problems with CDT Under Eclipse 3.3.0

Pretty messed up, reinstalled Eclipse 3.2.2...

Subversion Version Control System

More on using subversion on the techWiki here.

Installation

apt-get install subversion

installs the command-line client svn and the administrative tool svnadmin

Create Repository

svnadmin create /path/to/repos

e.g., /usr/local/lib/svn.

Structure your project to something like

/tmp/myproject/trunk/

where the trunk directory contains all the files and subdirectories.

For the initial import

svn import /tmp/myproject file:///path/to/repos/myproject -m "initial import"

To checkout the files to some directory

svn checkout file:///path/to/repos/myproject/trunk myproject

Using svn

Syntax

svn status
svn update
svn diff
svn revert
svn commit --message "..."=
svn add
svn checkout [URL]
svn log [name]
svn log/diff --revision (PREV,BASE,COMMITTED,PREV:COMMITTED,...,{2002-11-20},...)
svn copy/move/delete
svn propedit svn:ignore .

Always need to be in the right directory!

Workcycle

  • Update your working copy
svn update
  • Make changes
svn add
svn delete
svn copy
svn move
  • Examine your changes
svn status
svn diff
svn revert
  • Merge others' changes into your working copy
svn update
svn resolved
  • Commit your changes
svn commit

And Eclipse

If you use Eclipse (which you should;-), then see here for more information.

Server Configuration

If you would like to be able to access your repository via HTTP, either using

Apache (and the WebDAV/DeltaV protocol)

or

svnserve (automatically installed with snv and svnadmin)

I'll do the quick and easy configuration using svnserve as a standalone daemon process. However, to increase security it is advisable to create a dedicated svn user with limited permissions and start the deamon with this user. And don't forget to set the permission right for your repository filesystem, e.g.,

chown -R svn_user /path/to/repos/

Start deamon restricting the acces to the repository

svnserve -d -r /path/to/repos/

Permissions are set in the svnserve.conf file located at

/path/to/repos/conf/

Set

[general]
password-db = userfile
realm = example realm
# anonymous users can only read the repository
anon-access = read
# authenticated users can both read and write
auth-access = write

and in the userfile

[users]
user = password

Set the permission of userfile so only the svn_user can read.

By default, svnserve is listening on port 3690, so you'll have to open it to allow access from the web.

And don't forget to configure svnserve to start at system startup, otherwise, after a reboot you'll have an unprotected open port! So create a small bash script in /etc/init.d/, e.g.

#!/bin/bash
sudo -u svn_user svnserve -d -r /path/to/repos/

and set a symbolic link in /etc/rcS.d/ (see here for explanation)

ln -s ../name_of_script S**name

where ** in the link name stands for a number. Just go to /etc/rcS.d/ and

ls -la

and you'll understand.