2 Scripts to Make JavaFX + NetBeans Available on Linux

All the code comes from here and here. It worked for me, although I had to ignore 2 exceptions after this.

Update: JavaFX 1.0 only! See the first comment!

So first run:

mkdir javafxnbms
cd javafxnbms
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-api-debugger-javafx.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-debugger-javafx-ant.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-debugger-javafx-projects.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-debugger-javafx-ui.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-debugger-javafx.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-bestpractices.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-editor.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-fxd.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-lexer.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-lib.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-navigation.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-palette.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-platform.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-profiler.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-project.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-sdk-mac.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-sdksamples.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-source.nbm
wget http://updates.netbeans.org/netbeans/updates/6.5/uc/final/stable/modules/javafx/org-netbeans-modules-javafx-userlib.nbm

Then install the nbms via NetBeans: Tools -> Plugins -> Downloaded -> Add Plugins … and shutdown NetBeans (ignore the exception).

As last step run the following within the javafxnbnms folder:

mkdir unzipsdk
cd unzipsdk
unzip ../org-netbeans-modules-javafx-sdk-mac.nbm
cp -r netbeans/* ~/Programme/netbeans-6.5/javafx2/
chmod 755 ~/Programme/netbeans-6.5/javafx2/javafx-sdk1.0/bin/*

Restart NetBeans (ignore exception, disable the module -> it even works then!) and you should be able to create a JavaFX sample, run it, view it and change it.

Now you are able to help on timefinder 😉

No Warranty for that procedure!!

5-Line-Replacement of Apache Ant

rm -rf build/
mkdir build
jars=$(find ./lib/ -iname "*.jar" | tr  '\n' ':')
find ./src -iname "*\.java" > files.txt
$JAVAC_CMD -d build/ -cp $jars @files.txt

Okay, it is a very very unfair blog title – only an eye catcher!

But now you can bookmark this useful code snippet to compile your project without installing ant or even an IDE.

… and you could say: “Hey man – this is not platform independent!”.
But then I would say: “Oh yes it is! For windows you should install cygwin of course!”

Keep smiling 😉

Update: on windows with cygwin you have to replace the colon : with a semicolon ;

good to know about ubuntu (x-mas time)

Did you know that you could run ubuntu directly from windows? No? Then try out wubi!

And check out the following pages if you already are an interested (k)ubuntu user:

  • Playing DVDs, flash etc was a nightmare under suse 10.1. Under ubuntu > 8.04 it is a one-liner:
    sudo apt-get install ubuntu-restricted-extras

    Taken from here.

  • With VirtualBox you could try out new releases of ubuntu (or other OS’s). I used version 1.6.6 from here – the latest .deb package didn’t work for me.
  • Did you ever want your own customized ubuntu? Yes, the the following pages/projects are for you
  • UCK“is a tool that helps you customizing official Ubuntu Live CDs to your needs. You can add any package to the live system, for example language packs, or applications.” – taken from the website.
  • Very good tutorial to create your customized LiveCD. I tried it – really nice. In this way you can ‘present’ somebody with linux software 😉

Hope you have other ideas/pages for ubuntu and x-mas!

Codeweaver for free, to run windows programs under linux or mac

Only today you can get a license for free for the commercial wine version. Normally approx 40 EUR (to run window applications on linux). Why this? Read here.

I already bought this nice piece of software some months before 😦 to run origin under linux – and: it works 🙂

It was (relative) easy to get it working! I had only problems with the greek fonts and I simply copied those into linux – using suses font management.

Update

Now I got a license key. To install it under ubuntu try:

sudo dpkg -i crossover-standard_7.1.0-1_i386.deb

Then run

/opt/cxoffice/bin/cxbottlemanager

to install windows software under linux

Encoding issues. Solutions for linux and within Java apps.

Puh, encoding! Did you ever have trouble with it? No? You must be a lucky guy!

Even none-developers should have problems with it e.g. if they use different operating systems.

What is encoding? And what’s so difficult with the encoding?

First encoding (better: character encoding) defines how characters have to be saved to be displayed correctly in your editor or look at the wikipedia definition to be correct. Update: here is a nice introduction.

For example if your editor only reads ASCII files all is very simple: it will use every 8 bits of the bitstream to get a number. Then it will interpret this number according to the ASCII-table. So, if it finds a 97 (this is 0x61 in hexadecimal) it prints ‘a’.

(BTW: look at this nice ASCII-art.)

But what if the encoding is another one? Or if even the bitstream should be splitted into 16-bits-packages instead of 8-bits-packages?

Then the user won’t see the correct information!

Second: On linux everything is in UTF-8. Windows uses CP 1252. and so on. Not good!

(With everything I means: clipboard, default file encoding, …)

How can you (as an end user) handle this under linux?

There are at least 4 programs that helps you with encoding issues under linux:

  • There are command line utilities in linux where you can determine automatically the encoding of a file: enconv and enca or open the file in firefox and go to View -> Encoding and view the detected encoding!
  • To change the encoding of file-content the editor kate is really great:
    Go to extras -> encoding and try it out.
  • Change the encoding of the content of several files which come from windows and you want to have them in linux then use recode:
    recode CP1252..UTF-8 *
    recode ISO-8859-1..UTF-8 *

    do the following to backup the original files:

    mkdir test && cp * test/ && cd test
  • Another command line utility is iconv (or here)
  • Change the encoding of the filenames with convmv (files e.g. from windows).
    To preview the change do:

    convmv -f cp1252 -t utf8 *

    To do the change:

    convmv --notest -f cp1252 -t utf8 *

How does Java handle encoding?

Java is platform independent one should think, but it isn’t regarding to the encoding.

For example: if you read a file correctly under linux, this could fail if you don’t specify the encoding explicitly, because it assumes it is utf8 and under windows it will use another default!

To override the default use: ‘java -Dfile,encoding=UTF-8’ or be explicit with the encoding! E.g read characters from a stream with the following lines:

BufferedInputStream iStream = new BufferedInputStream(urlConn.getInputStream());
InputStreamReader reader = new InputStreamReader(iStream, "UTF-8");

Another issue could be Java source files. They can have different encoding. You should use UTF8, because this is the encoding Java uses for its Strings.

In NetBeans 6.1 change it in the project properties (right-click on the project->properties)->Source->Encoding

In Eclipse 3.4 go to the preferences (menu Window) -> General ->Workspace->text file encoding

But this is only useful for desktop applications like my open source timetabler. But what if you do web development? All fine there? No not really. Then you might get additional problems with url encoding or xml parsing. For the latter one the fix is simple:

  • XML: <?xml version=”1.0″ encoding=”UTF-8″?>

But for url encoding the following does not really work:

  • JSP: <%@page contentType=”text/html; charset=UTF-8″ language=”java”%>

Apropos JSP – I had an encoding issue with the request. Try the following:

<% out.print(“RESPONSE character encoding=” + response.getCharacterEncoding() + ” “);
out.print(“REQUEST character encoding=” + request.getCharacterEncoding() + ” “);
out.print(“JVM encoding ” + System.getProperty(“file.encoding”) + ” “);

//EVEN here we get request parameter in wrong encoding
bean.setRequest(request);
%>

You will see that the request is null if I am not wrong. And then Java will use utf8? NO!

It will use ISO-8859-1! Why? It is written in the standard!

A simple request.setCharacterEncoding(“UTF-8”); would help if all browsers would send its request according to the header of the jsp. But this isn’t actually working for my use case. So I grabbed the strings from the request via this helper method:

private String toUTF8(String str) {
        try {
            return new String(str.getBytes("8859_1"), "UTF8");
        } catch (UnsupportedEncodingException ex) {
            return str;
        }
}

Update 1: Read this or this to get a better workaround with a javax.servlet.Filter, webserver parameters and jsp configs.

Update 2: The following snippets could be useful if you are using maven and want to make the application UTF-8 aware:

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

Update 3:

A good side with a lookup table for Unicode characters

http://unicode.coeurlumiere.com/

Summary

I invite you to post all your experiences with encoding problems in java.
E.g. how to force jboss or jetty to use utf8?

Canon ip 4200 under linux

My experiences under linux with the canon printer are great. Installation works like it is described in the manual for Suse 10.0 (I tried it only for 10.1).

One strange thing you have to know under linux, if you refilled the printer. The printer will stop printing if it was refilled. One button of the printer will blink, which normally indicates missing paper, so I was confused that pressing on the button does not help. So, what was wrong?

You have to press the button a long time (5 seconds or so). This way Canon makes sure you read the message (which will pop up under windows only) and you confirm that you will lost the warranty with that action.

Nice, isn’t it? Hmmh …

The installation of your canon ip4200 printer under kubuntu 8.04.1

looks like described here.

I will try to translate it into English now:

  • Download the tar file (with rpms) from this site.
  • sudo alien -c cnijfilter-common-2.60-1.i386.rpm cnijfilter-ip4200-2.60-1.i386.rpm
    You should get the following info:
    “cnijfilter-common_2.60-2_i386.deb generated
    cnijfilter-ip4200_2.60-2_i386.deb generated”
  • Now install the transformed packages:
    sudo dpkg -i cnijfilter-common_2.60-2_i386.deb
    sudo dpkg -i cnijfilter-ip4200_2.60-2_i386.deb
  • Restarting cups should give you an okay:
    sudo /etc/init.d/cupsys restart
  • The driver file is located at: /usr/share/cups/model/canonip4200.ppd
    Specify this while configuring your printer in KMenu->Systemeinstellungen (Systemproperties?)->Printer
    Define it as standard printer
  • Now you can install an additional program to see more details of your printer:
    sudo apt-get install escputil

The clue about this installation is that you have more options in resolution and color models than in Suse 10.1

Kubuntu 8.04.1 not only for Java Developers

Today I switched from Suse 10.1 to Ubuntu 8.04.1 because of the smoother upgrading mechanism of debian. All people who already knows ubuntu won’t learn sth. from this post, so don’t waste your time 😉

Now all seems to work what I need as a ‘normal’ user:

  • mp3, just start amarok and install the necessary packages
    To install the ability that you can burn mp3 files with k3b do

    sudo apt-get install libk3b2-mp3
  • dvd, just start kaffeine and run the provided script in the console.
  • 3d + desktop effects. To enable your 3d graphic card click the hardware info and make the propriatary 3d-support active. Thats it. Ubuntu will do the rest for you. The same is true for the desktop effects. Go to the K-Menu->System->Desktop Effects and install it.
  • skype: add the following line to the file /etc/apt/sources.list
    deb http://download.skype.com/linux/repos/debian/ stable non-free
    and do
    sudo apt-get install skype
  • If you need an import/export tool for thunderbird then try this.
  • flash with
    
    sudo apt-get install flashplugin-nonfree
  • grip to grab your cds, inkscape for your svg images, gimp for other images, kgpg to encrypt sth.,

The only real problem was that thunderbird and firefox have some problems with the layout. And be sure that you DO NOT use the provided thunderbird 2.0.0.16 because it does not work with lightning. Download 2.0.0.14 and get lighning 0.8.

Now we will go on to install things that we need as Java-developers. All is very simple and straightfoward:

Install Java 1.6

sudo apt-get install sun-java6-jdk
sudo update-java-alternatives -s java-6-sun

To set open jdk as the default use ‘update-java-alternatives -s java-6-openjdk’. Use ‘update-java-alternatives -l’ to list the installed jvms. Or use:

sudo update-alternatives –config javac
sudo update-alternatives –config java

Install NetBeans 6.1

Via https://help.ubuntu.com/community/Netbeans

or install NetBeans 6.0.1 more easily via:

sudo apt-get install netbeans

I had trouble to start NetBeans with sun-java5-jdk, even with the next procedure where I installed the very latest version. Download the .bin file directly from sun and convert it into .deb via:

sudo apt-get install java-package
sudo apt-get install fakeroot
fakeroot make-jpkg jdk-1_5_0_16-linux-i586.bin

A lot of warnings will appear. But as a result you should get the .deb file and do:

sudo dpkg -i sun-j2sdk1.5_1.5.0+update16_i386.deb

It will install the java not in /usr/lib/jvm but in /usr/lib/j2sdk1.5-sun/

Now you should be able to start netbeans with jdk5:
/home/user/netbeans-6.1/bin/netbeans --jdkhome /usr/lib/j2sdk1.5-sun --fontsize 14
But the problem is that I do not see the window content as with sun-java5-jdk ...

Install Eclipse 3.4

http://jhcore.com/2008/06/26/eclipse-34-ganymede-on-ubuntu/

or install Eclipse 3.2 via:

sudo apt-get install eclipse

Other things you can install: kdesvn, kdevelop, ..., extremetuxracer ;-)

For interested users I will post here the menu.lst for my semi-complicated OS
and disc constellation. Maybe it will be usefull for others.

I have two hard discs:
# device.map
(hd0)   /dev/sda
(hd1)   /dev/sdb

My system boots from the sata disc (sda) and can start the old suse on sda
and the new system on sdb (an ide disc).
It would have been very tricky to figure out how I can start windows which is located at sda,
but all the stuff was done from kubuntu! I don't know how, but it is great.
To install the menu list do sudo grub-install /dev/sdb

One question to my reader: were can I get the UUID?

# Now menu.lst
## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
default         0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout         7

title           Ubuntu 8.04.1, kernel 2.6.24-19-generic
root            (hd1,5)
kernel          /boot/vmlinuz-2.6.24-19-generic root=UUID=3fce55c4-6d4f-4d88-b947-483acce2e7ee ro quiet splash
initrd          /boot/initrd.img-2.6.24-19-generic
quiet

title           Ubuntu 8.04.1, kernel 2.6.24-19-generic (recovery mode)
root            (hd1,5)
kernel          /boot/vmlinuz-2.6.24-19-generic root=UUID=3fce55c4-6d4f-4d88-b947-483acce2e7ee ro single
initrd          /boot/initrd.img-2.6.24-19-generic

title           Ubuntu 8.04.1, memtest86+
root            (hd1,5)
kernel          /boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title           Other operating systems:
root

# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda1.
title           SUSE Linux 10.1 (on /dev/sda1)
root            (hd0,0)
kernel          /boot/vmlinuz root=/dev/sda1 vga=0x31a resume=/dev/sda5 splash=silent showopts
initrd          /boot/initrd
savedefault
boot

# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda1.
title           Failsafe -- SUSE Linux 10.1 (on /dev/sda1)
root            (hd0,0)
kernel          /boot/vmlinuz root=/dev/sda1 vga=normal showopts ide=nodma apm=off acpi=off noresume nosmp noapic maxcpus=0 edd=off 3
initrd          /boot/initrd
savedefault
boot

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sdb3
title           Microsoft Windows XP Professional
root            (hd1,2)
savedefault
makeactive
map             (hd0) (hd1)
map             (hd1) (hd0)
chainloader     +1

No OOXML

OOXML is now ISO standard!

OOXML will divide the (internet) communication into a Microsoft-world and the rest. With the doc-format MS started the ‘way of division’ and now they will be successful!?

Finally I call on users all around the world to look to Norway and follow the example we have set. Raise a storm of protest! Uncover the irregularities that have taken place in your country! Insist that your Governments change their vote to reflect the interests of ordinary people and not the interests of monopolists and bureaucrats.” — Steve Pepper

So, nevertheless go to http://www.noooxml.org/petition and see the reasons, why OOXML shouldn’t be a standard.

Discovered a Linux Security Hole

Problem

The following procedure is not a critical security issue, but you should have this in mind if you powersave your computer the next time.

  1. Start some programs, which will capture alot of RAM. Sometimes it works with less programs 😉
  2. powersave -U
  3. Restart you computer and wait until you see a black monitor (Sometimes some characters are on it). Only 2 or 3 seconds later you will see the desktop for only a very short time.
  4. In this time frame (you see the desktop!) you can press ALT+TAB one or more times until the list of window (to choose the application) pops up. Now hold the ATL key and wait until …
  5. You see a black monitor again, but no screesaver will appear. This is the bug! You can release the ALT key, if the black monitor is replaced from your desktop image or so.
  6. Now you can do all things without a password typed in!

I posted this issue to the kde security mailing list, but I got no responds (Maybe it was the wrong addressee or not a big issue…).

This works for me on my suse 10.1 (i586) on all window managers (kde, windowmaker, …).

(2.6.16.21-0.25-default1 kernel, powersave 0.12.20)

Conclusion

If you now think linux is weak in respect to security relevant stuff, I think you are wrong and right at the same time. Because the core linux system of linux (kernel + some apps like shells) are mature and very secure. But if you install a lot open source programs, which can be in alpha or beta status you might get security problems. So the best you can do is update you software or disconnect from internet 😉