2008-11-25

Using Windows registry with Java

Needed a way to store (and retrieve) strings on a local host from a Java application. Found some JNI-ways but that didn't feel "pure". Solution was java.util.prefs as in:


import java.util.prefs.*;

public class Main {
static Preferences prefs;

public static void main(String[] args) {

prefs = Preferences.userRoot();
String Installed = "";
String Name = "";
String def = "NA";

try {
Installed = prefs.get("Installed", def);
Name = prefs.get("Name", def);
} catch(Exception e) {
e.printStackTrace();
}
System.out.println("Installed: " + Installed);
System.out.println("Name: " + Name);

if(Installed.equalsIgnoreCase("NA")) {
prefs.put("Installed", new java.util.Date().toString());
prefs.put("Name", "jonas testar");
}

System.out.println("Date: " + new java.util.Date().toString());
}
}


Quite easy when one know how to do it.

prefs = Preferences.userRoot(); means that we are using HKEY_CURRENT_USER tree in registry. userRoot() can be changed to systemRoot()..

2008-04-22

Disable tapping with Synaptics touchpad

I don't like when my touchpad clicks because of tapping. With MaxTapTime I could disable this function. When I surf the net with Firefox and touched the lower area on the touchpad Firefox goes back/forward, this could be disabled with HorizScrollDelta . Look in your /etc/X11/xorg.conf file :


Section "InputDevice"
Driver "synaptics"
Identifier "Mouse[1]"
Option "Buttons" "5"
Option "Device" "/dev/input/mice"
Option "Emulate3Buttons" "on"
Option "InputFashion" "Mouse"
Option "Name" "Synaptics;Touchpad"
Option "Protocol" "explorerps/2"
Option "SHMConfig" "on"
Option "Vendor" "Sysp"
Option "MaxTapTime" "0"
Option "HorizScrollDelta" "0"
Option "ZAxisMapping" "4 5"
EndSection

2008-03-03

Fan control on HP Proliant ML370 G3

I have a HP Proliant ML370 G3 at school running Ubuntu 7.10 . One of the biggest issues with the server is that it is in classroom and the fans running at high speed making noise.

Found some info about this on the net, but everyone seemed to using alien to convert RPMs for Red Hat to Ubuntu (or Debian). I found Debian packages at HP's website and this is how i lowered my fans in the server.

  1. Go to hp.com and select Debian 4.0 (Etch) - HP ProLiant Value Add Software i386 .
  2. Fill in the form and select hpasm-7.8.0-100.etch26.i386.deb in Software Specification .
  3. Download the file to the server.
  4. hpasm needs snmpd and libstdc++2.10-glibc2.2 installed:
    $ sudo apt-get install snmpd libstdc++2.10-glibc2.2
  5. Install hpasm:
    $ sudo dpkg -i hpasm-7.8.0-100.etch26.i386.deb
  6. Of some reason Ubuntu uses the shell DASH instead of BASH. That created the following error message: /opt/compaq/hpasm/etc/foundation.functions: 502: Syntax error: Bad substitution . Solution for this is to change the symbolic link /bin/sh to /bin/bash:
    $ sudo rm /bin/sh
    $ sudo ln -s /bin/bash /bin/sh
  7. Start hpasm :
    $ sudo /opt/compaq/hpasm/etc/hpasm start
Note that the error descibed in 6 is if you don't relink /bin/sh to /bin/bash.

2008-02-26

GroupWise client in Ubuntu

I am using Novell GroupWise for my email at work and had some problems installing the Linux GroupWise client in Ubuntu 7.10. This is how I got it to work.

Before you start, make sure you have Java6 installed. If not install sun-java6-jre :

$ sudo apt-get install sun-java6-jre

First I downloaded the client from http://download.novell.com/ (requires a free Novell account). The client is shipped in a tar-gz archive: gw701clnxm.tgz .

When extracting it I got two RPM:s to install from, the client is in novell-groupwise-gwclient-7.0.1-20060613.i386.rpm . Ubuntu doesn't do RPM:s so well, so I installed alien:

$ sudo apt-get install alien

With alien I could convert the RPM to a DEB-package, that is installable in Ubuntu:

$ sudo alien -c novell-groupwise-gwclient-7.0.1-20060613.i386.rpm

After converting I got novell-groupwise-gwclient_7.0.1-20060614_i386.deb in the same folder as the RPM. Now it was time to install the DEB in Ubuntu:

$ sudo dpkg -i novell-groupwise-gwclient_7.0.1-20060614_i386.deb

To start the GroupWise client I typed:

$ /opt/novell/groupwise/client/bin/groupwise

Everything seemed to work, but the client went all grey. I got an idea that it might be the JRE (Java) that GroupWise is shipped with that was the problem. So I deleted the jre-directory and symlinked it to java-6-sun :

$ sudo rm -rf /opt/novell/groupwise/client/jre
$ sudo ln -s /usr/lib/jvm/java-6-sun/jre /opt/novell/groupwise/client/jre

Now everything was working.


To get an nice GroupWise icon on your desktop, just copy the .desktop file:

$ cp /opt/novell/groupwise/client/gwclient.desktop ~/Desktop/

GNOME Bluetooth

I tried to browse my cellphone from the bluetooth-applet in GNOME and got an ugly error.


Translated to english it would be:

"obex://[00:19:63:96:52:b2]" is not a valid location.

Solution was to install gnome-vfs-obexftp:

$ sudo apt-get install gnome-vfs-obexftp

The problem seems to be that Nautilus doesn't support (understand) the OBEX-protocol. This should have been installed with the bluetooth-applet..

2008-02-25

Xnested

I wanted to take some screenshots from Ubuntu for some educational material I am writing. I was wondering how I could take a screenshot on login without running Ubuntu in a virtual environment.

I found xnest. xnest runs a x server inside the running x server. Installed by:

$ sudo apt-get install xnest

Then I used the command gdmflexiserver to start a GDM inside of xnest:

$ gdmflexiserver -n


I noticed that I could not login as the same user that had started gdmflexiserver. I created a new account on my computer and login went fine.

2008-02-22

You want the sources for SUSE Linux Enterprise (SLE)-products? They are kind of hard to find, but there is sources available:
Good luck!

2008-02-21

I am writing a book about Java 6 programming, the basics. My intention is to use it at my work as a teacher in high-school. First I used LaTeX for typesetting the book, LaTeX is nice I think. But today I suddenly changed my mind and converted it to DocBook/XML . Don't ask me why - I just thought it was a good idea.

So there I was, five chapters written and ready for being sent to my friend for proof-reading. Typed the command:

$ jw -f docbook -b pdf dtr1207.xml

I got many errors like this:
openjade:/home/jonas/dtr1207-java/dtr1207.xml:303:9:E: non SGML character number 150

It seemed to be the char "Ö" that were the problem. I changed it to "ö" and the pdf were built fine. But I couldn't change every Ö in my text to ö just because of a stupid buildprocess. Google wasn't very helpful either. Then suddenly I read about SP_ENCODING.

$ SP_ENCODING="UTF-8" jw -f docbook -b pdf dtr1207.xml


SP_ENCODING can be set to XML or UTF-8. If it is set to XML it will read the XML-tag in document and use that encoding, I choosed to force it to be UTF-8.