Subject: Success running Eclipse and Sun JDK 1.4.2 under NetBSD -current
To: None <current-users@netbsd.org>
From: Brian de Alwis <bsd@cs.ubc.ca>
List: current-users
Date: 03/25/2004 11:48:52
--Boundary_(ID_OynPr2sKZG6HJdjQYKpmgg)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
Content-disposition: inline

A quick summary: the Sun JDK 1.4.2 runs on NetBSD-current happily
enough to run Eclipse, a fairly demanding application.

I'd been wanting to try out Eclipse (a Java IDE) using its GTK
bindings, but our Linux emulation packages don't support the required
GTK2.  Seeing that Greg Lewis has released patchset 6 for the JDK
porting effort to FreeBSD (see below)], I thought I'd give try
running Eclipse `natively' on NetBSD.  Although listed as being
alpha quality for NetBSD, I've had no problems: I'm able to run
and debug applications, edit files, run SWT apps, etc. etc.

The build/install was dead easy -- far easier than I expected --
thanks to Christos Zoulas who has been helping ensure portability
to NetBSD.  Unfortunately we can't redistribute the JDK builds:
I think the NetBSD Foundation will have to pursue this with Sun as
with the FreeBSD Foundations
(http://www.freebsdfoundation.org/downloads/java.shtml).

I'd like to give a big thanks to Greg Lewis and the other *BSD Java
porters.  Amazing to see this work.

 0. You'll need to download everything in
    <http://www.eyesbeyond.com/freebsddom/java/jdk14.html>.
    The build process uses an existing Java installation for
    building: you should install lang/sun-jdk14.

 1. The installation runs some Java applications requiring very large
    data segment sizes, sometimes as great as 350M.  As I built
    this as a normal user, this was greater than the allowable data
    segment size, and I found it easiest to circumvent this using
    sysctl; find out the pid of your building shell (`echo $$'),
    and in another shell invoke

	sudo sysctl -w \
	    'proc.3409.rlimit.datasize.hard=350000000' \
	    'proc.3409.rlimit.datasize.soft=350000000'

    where 3409 is the pid of your shell, of course.

 2. Now follow the build instructions: extract the source, patch
    the source.  Commence the build.

 3. The build will fail at a certain point, as a build directory
    has not been properly created. 

	mkdir ../build/bsd-i586/lib/i386/server

    And resume the build.  It may be that this can be done before
    step #2.  You should have no other problems during the build.

 4. Once the build completes, try out the resulting binaries:

	export JAVA_HOME=<buildroot>/build/bsd-i586
	$JAVA_HOME/bin/java -version
	$JAVA_HOME/bin/javac -version

    You could also try running some Java programs.

 5. Assuming the JVMs work, you need to run the install target to
    build yourself some distribution zip files, so you can install
    it somewhere else:

	gmake install
	cp ../build/bsd-i586/bundles/j2sdk-1_4_2-p6-bin-bsd_*.tar \
	    <safeplace>

 6. Deploy the resulting JDK: unzip it somewhere safe.  If you
    run Mozilla or Galeon or whatever, the Java plugin is available
    as <.../j2sdk1.4.2/jre/plugin/i386/ns610/libjavaplugin_oji.so>.
    Put a symbolic link to your browser's plugin directory, and you're
    set!

If you want to run Eclipse:

 1. Download the appropriate version of Eclipse and SWT from the
    Eclipse website <http://www.eclipse.org/download/>.  You'll
    need one of the SWT binary packages for Linux GTK or Motif.
    Unzip the Eclipse install somewhere.  Unzip the SWT build
    somewhere else and follow the instructions; you'll need to fix
    up the Makefile, but building the SWT libraries is pretty
    straight-forward.

 2. Put the SWT directory with your libswt*.so files
    in your LD_LIBRARY_PATH.

 3. Instead of running the provided eclipse binary, we'll do the
    equivalent, where `gtk' should be `motif' if running the Motif
    SWT, ${SWTDIR} is your SWT directory from #2, and $ECLIPSEDIR
    is your Eclipse root, 

	java -classpath $ECLIPSEDIR/startup.jar -Djava.library.path=${SWTDIR}
	    org.eclipse.core.launcher.Main -arch x86
	    -os bsd -ws gtk

    That should be it!  I've attached a slightly nicer script here,
    as well as usejava(1) which is a handy script to change between
    JVMs.

Brian.

Proposed patch for problem 3.  I *think* these might work: I
didn't try them as rebuilding this to identify the problems above
took long enough :-(
--------------------------------------------------
--- j2se/make/common/Rules.gmk.orig      2004-03-24 13:47:07.000000000 -0800
+++ j2se/make/common/Rules.gmk   2004-03-24 13:47:34.000000000 -0800
@@ -12,7 +12,7 @@
 #
 # Directory set up.
 #
-$(CLASSDESTDIR) $(CLASSHDRDIR) $(OBJDIR) $(OUTPUTDIR) $(BINDIR) $(LIBDIR) $(LIBDIR)/$(LIBARCH) $(TMPDIR) $(EXTDIR):
+$(CLASSDESTDIR) $(CLASSHDRDIR) $(OBJDIR) $(OUTPUTDIR) $(BINDIR) $(LIBDIR) $(LIBDIR)/$(LIBARCH) $(LIBDIR)/$(LIBARCH)/$(VM_NAME) $(TMPDIR) $(EXTDIR):
        $(MKDIR) -p $@
 
 #

--- j2se/make/common/Library.gmk.orig-2  2004-03-24 14:06:46.000000000 -0800
+++ j2se/make/common/Library.gmk 2004-03-24 14:06:51.000000000 -0800
@@ -80,7 +80,7 @@
 
 else # PLATFORM
 # create the LIBDIR/LIBARCH directory for non-windows platforms.
-$(OPTIMIZED) $(DEBUG):: $(LIBDIR)/$(LIBARCH)
+$(OPTIMIZED) $(DEBUG):: $(LIBDIR)/$(LIBARCH) $(LIBDIR)/$(LIBARCH)/$(VM_NAME)
 endif # PLATFORM
 
 #

--------------------------------------------------



-- 
     Brian de Alwis | Graduate student | Software Practices Lab | UBC
"There is much pleasure to be gained in useless knowledge." - Bertrand Russell

--Boundary_(ID_OynPr2sKZG6HJdjQYKpmgg)
Content-type: text/plain; charset=us-ascii; NAME=eclipse-bsd
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=eclipse-bsd

#!/bin/sh
. $BINPATH/tools.sh

ECLIPSEDIR=${ECLIPSEDIR:-/usr/local/installs/eclipse-3.0M7-gtk}
SWTDIR=${SWTDIR:-/home/scratch/swt/swt}
#eval `usejava /home/scratch/sun-jdk-1.4/src/control/build/bsd-i586`

ECLIPSE_ARCH=${ECLIPSE_ARCH:-x86}
ECLIPSE_OS=${ECLIPSE_OS:-bsd}
ECLIPSE_WS=${ECLIPSE_WS:-gtk}

min_datasize=256000
JVMMEMORY=140m

prepend LD_LIBRARY_PATH /home/scratch/bsd/swt/swt/
export LD_LIBRARY_PATH

workspacedir=`dirname $0`/workspace

if [ `ulimit -d` -le $min_datasize ]; then
    echo "Bumping up datasize limit to $min_datasize"
    sudo sysctl -w \
	"proc.$$.rlimit.datasize.hard=`expr $min_datasize \* 1024`" \
	"proc.$$.rlimit.datasize.soft=`expr $min_datasize \* 1024`"
fi
ulimit -c 0

if [ -f $workspacedir/.metadata/.lock ]; then
    echo "Removing .lock..."
    rm $workspacedir/.metadata/.lock
fi

# -vmargs -Xmx${JVMMEMORY} 
set -x
exec java -classpath $ECLIPSEDIR/startup.jar \
    -Djava.library.path=${SWTDIR} org.eclipse.core.launcher.Main \
    -arch ${ECLIPSE_ARCH} -os ${ECLIPSE_OS} -ws ${ECLIPSE_WS} \
    -nosplash -data "$workspacedir" "$@"


--Boundary_(ID_OynPr2sKZG6HJdjQYKpmgg)
Content-type: text/plain; charset=us-ascii; NAME=usejava
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=usejava

#!/bin/sh

. $BINPATH/tools.sh

if [ $# -lt 1 ]; then
    echo "use: $progname java_home [jre_home]"
    exit 1
fi

export JAVA_HOME=$1
if [ -n "$2" ]; then
    export JRE_HOME=$2
elif [ -d $JAVA_HOME/jre ]; then
    export JRE_HOME=${JAVA_HOME}/jre
else
    export JRE_HOME=${JAVA_HOME}
fi
export JDK_HOME=${JAVA_HOME}
#export ANT_HOME=${ANT_HOME:-/data/software/ant}
#export ASPECTJ_HOME=${ASPECTJ_HOME:-/data/software/aspectj0.7b11}
#prepend PATH $ANT_HOME/bin $ASPECTJ_HOME/bin $JAVA_HOME/bin
prepend PATH $JAVA_HOME/bin

#$ASPECTJ_HOME/lib/*.jar \
CLASSPATH=""
buildpath -f CLASSPATH . \
    $JRE_HOME/lib/rt.jar \
    $JAVA_HOME/lib/classes.zip \
    $JAVA_HOME/lib/tools.jar \
    $JAVA_HOME/lib/*.jar \
    $JRE_HOME/lib/*.jar
export CLASSPATH

echo PATH=$PATH
echo CLASSPATH=$CLASSPATH
echo JAVA_HOME=$JAVA_HOME
echo JDK_HOME=$JDK_HOME
echo JRE_HOME=$JRE_HOME
echo export PATH CLASSPATH JAVA_HOME JDK_HOME JRE_HOME

--Boundary_(ID_OynPr2sKZG6HJdjQYKpmgg)--