thimsen on tech

Wednesday, February 23, 2005

Lotus Notes in Linux? You bet!

You though you couldn't switch causes you'd be with out your notes client? Think again. I have outlined some easy steps to get notes running in your Linux environment.


I have read of people having success installing notes without a windows environment, I haven't done it myself. You may want to research the option on your own.


Wine? Is it a good year?


“Yeah, I like wine, matter of fact I could use a nice 1987 Cabernet Sauvignon right now, but what does that have to do with Linux?” Don't worry you're not the first to ask. In reality it Wine has a lot to do it!


Wine makes it possible to run Windows programs alongside any Unix-like operating system, particularly Linux. At its heart, Wine is an implementation of the Windows Application Programing Interface (API) library, acting as a bridge between the Windows program and Linux. 1


For move information on Wine, visit the web, http://www.winehq.com/site/docs/wine-user/what-is-wine. Additional Wine resources are located in the References section at the end of this document.


Installing Wine


Wine comes as part of many Linux distributions. Make sure you have the latest version installed. The easiest way to get Wine is to download the package files from:

http://sourceforge.net/project/showfiles.php?group_id=6241


Most distributions provide a graphical tool for installing RPM packages, you can use it by simply clicking (Or double clicking, depending on your system settings) on the RPM. If you don't have a graphical RPM manager installed, using a shell, switch to the directory where you downloaded the RPM package file to. Once there, type this one command as root, adapting the package file name as required:

   # rpm -ivh wine-20031212.i386.rpm   

For more info on installing Wine visit

http://www.winehq.com/site/docs/wine-user/installing


Installing Notes Under Wine


Now to the good stuff! Wine sets up a Windows dir structure, under your home directory, (i.e. /home/user1). You can test your install by running by opening a console and typing,

wine notepad.exe

I have found the fastest way to get notes up and was to copy an working Notes install on a Windows box to the wine environment.

Copy c:\Program Files\lotus from you windows box

to

~/.wine/drive_c:/Program Files/ on your Linux box.


UPDATE: (2006-02-25)

run winecfg and add nlnotes.exe as an app, set OS to win98. Then goto dll overrides and add usp10 and set to native.


You can test your notes client by opening a console and typing,

wine "c:\program files\lotus\notes\nlnotes.exe"


Screen Shot 1Notes Client with incorrect directory permissions















If you get the a file browser box titled “Notes Directory Inaccessible”, Screen Shot 1, ensure that the notes directory you copied over is writable by you.


You can check the directory permissions through the GUI or command line. Modify the directory permissions by opening a console and typing,


chmod -R 744 ~/.wine/drive_c/Program\ Files/lotus


In some cases, Wine may complain that there's no config file. If so, just copy the system.reg file in .wine/:

cp system.reg config


This configuration has been found to work with Notes 6.5 and Wine-20040615 and Notes 6.5.2 and Wine-20040813.

When it's working, define aliases in ~/.bashrc: (should be on two lines)

    alias lotus="wine \"c:\program files\lotus\notes\nlnotes.exe\" \ 
    > ~/tmp/winelog 2>&1"

    alias notes="wine \"c:\program files\lotus\notes\nlnotes.exe\" \
    > ~/tmp/winelog 2>&1"

Everyday things seem to work ok, and performance is much faster than my previous configuration (Notes 5.5 under Wine-20040408). However, editing settings/preferences often causes it to crash/hang. When this happens, type killall wine-preloader and restart Notes. This suggests that, at least until the next version of Wine comes out, it's a good idea to do all necessary configuration on the Windows box before copying it to Wine. Of course, you can always copy a fresh lotus directory tree to Wine.2

Update: Using Notes 6.5.2 and Wine-20040716 seems to have fixed at least some of the crashing when editing preferences.

Update: Using Wine-20050930 notes fails to start. I had to run winecfg and set the default to Win98. In addition I copied over the usp10.dll to the windows/system directory. Back up and rockin!



Not sure this needs saying, but you can continue to run your Windows version, since all the data is replicated to the Domino server and clients will sync automatically.














References

http://www.winehq.com

2http://www.tux.org/~tbr/lotusnotes/notes6underwine.html

Tuesday, February 22, 2005

Installing a Java Decompiler for Linux

Java compiler compiles the Java source code files (*.java) into binaries files (*.class). You would use the Java de-compiler to convert java class files into source code files (*.java).

Java de-compiler has some very useful and legitimate uses, especially if you have *.class files and you do not have access to the source code. Some vendors do not ship the source code for java class files, in which case you use the java decompiler to look at the source code and generate a deeper understanding of the code. [1]

There are many different free for non-commercial uses Java decompilers. There are also a few commercial products. In this article we will use an excellent free product called, JAD (JAva Decompiler).



Download and Install JAva Decompiler


First step is to download JAD. http://kpdus.tripod.com/jad.html


Find your OS and platform. For this example I used Linux on Intel platform.


Extract the zip file.


Make sure the jad file is in your PATH.


To view your PATH type:


thimsen@linuxdev:~> echo $PATH

/home/thimsen/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:
/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/jvm/jre/bin

On my system my /home/thimsen/bin folder was listed in my path so I copied the jad executable there. You could place the jad executable file elsewhere on your system just be sure to include it in your PATH.



thimsen@linuxdev:~> cp downloads/jad bin

Then verify that the jad file has executable permissions set.


thimsen@linuxdev:~> chmod 775 bin/jad

thimsen@linuxdev:~> ls -l bin

total 577

-rwxrwxr-x 1 thimsen users 836 2005-02-22 20:42 decomp.sh

-rwxrwxr-x 1 thimsen users 568228 2001-08-05 15:50 jad

Now you are ready to start decompiling. Open a console and run jad with a .class file you want to decompile as it's argument.


thimsen@linuxdev:~> jad CounterServlet.class

Parsing CounterServlet.class... Generating CounterServlet.jad

Jad generates an .jad file which contains the source code generated from the class file you specified. You can view the file with your favorite file editor (vi, emacs, nano).


Setting up a GUI


Now that you can decompile Java classes from the command line, lets take it to the next step. It's a hassle to locate your class file and type the jad commands into the console every time you want to decompile a file.


Let's setup a shell script to take care of the typing for us. Create a file called decomp.sh in your home/bin directory or somewhere in your PATH. Make sure it has executable permissions like the jad executable file. Paste the script below into the decomp.sh file.





#!/bin/bash

#

#

#

# Decompiles a compiled java class (.class) with jad then opens

# resulting file in kwrite

#

# Usage: decomp.sh

#

#set up environment

JAD_DIR=~/.jad

FILE=$1

EXT=jad


# check to see if tmp dir '.jad' exists

# if it doesn't create a the 'jad' folder in the users $HOME dir

if [ ! -d $JAD_DIR ]; then mkdir $JAD_DIR; fi

jad -o -d $JAD_DIR -s$EXT $FILE


# Chop off the path-to-file and '.class' extension

# This RE extracts $substring at the end of $FILE

# Precondition: FILE= /.*[\/.*]*[.]

# Result: /.*[.]

SUBSTRING=".*\/.*[.]"

NEWFILE=`expr "$FILE" : '.*\('$SUBSTRING'\)'`


# open decompiled file in file editor

# (replace 'kwrite' with your fav file editor)

kwrite $JAD_DIR$NEWFILE$EXT


# remove the '.jad' file from tmp dir

#rm $JAD_DIR$NEWFILE$EXT


The script creates a folder named '.jad' in your home directory to store the decompiled Java classes. This allows you to decompile classes in directories which you don't write access. If you uncomment the last line of the script, (delete the # symbol), it will automatically clean up the decompile Java file after you close you file editor. A common modification is to change the file editor in which the script opens the decompiled Java code. The third to last line starts with, kwrite. If you wish to you a different GUI file editor or do not have kwrite installed simply replace kwrite, with the name of the editor you wish to use.


Screen Shot 1


Now that we have the script written we need to associate it with .class file extensions. The way to associate files with commands varies by Linux flavor and the window manager you are using. In this example I am using SuSE Linux 9.2 running KDE.


Open a Konqueror window and locate a Java class file you wish to decompile. Either left click on the class file or right click and choose (Open With...).



You should see a dialog like the one in Screen Shot 1. Either type in the path or browse to your decomp.sh file. Click OK. Now whenever you click on any Java class files they will open up in your selected file editor decompiled!



References


[1] Java Decompiler HOW-TO

http://www.faqs.org/docs/Linux-HOWTO/Java-Decompiler-HOWTO.html


[2] Jad – The Fast JAva Decompiler
http://kpdus.tripod.com/jad.html