Samuel Kroslak’s blog

Archive for December 2007

Sample Ant script for small projects

without comments

I don’t know yet how to put there ant code in a way that it will not conflict with wordpress tags, so build file is attached here:
build.xml

This script is assuming that you follow some basic conventions. You need to do only 2 things to adapt it to your project.

  1. change project name to your project name in 1st line of script
  2. set path to your main class in “mainClass” property.

Then you are ready to go. Assuming you have all your source files and resources in ’src’ folder and dependent libraries in ‘lib’ folder, script can generate .jar file (including libraries), javadoc and some stuff around those.

I was searching for something similar and universal to use in my small projects and I didn’t find anything like that, so I created it myself.

Written by Samuel Kroslak

December 15, 2007 at 19:07

Posted in Java

Tagged with ,

Deploy your Java application as one .jar file

without comments

At first, I wanted a tool that will pack everything into one simple .jar file and I can deploy my apps on web thrugh JWS more easily then. However, as far as I was playing with JWS vs. tools to pack app into one .jar, I found that this approach brings more problems than solutions. Whatever, tools I found for packing apps as one .jar are:

  1. JPackIt – best I found, but has serious issues with JWS, and JWS is generally only case in which I’m interested in deploying app as single JAR file.
  2. Fat Jar – is great, but drawback/advantage is that it is Eclipse plug-in. I just love Eclipse, but I need to do my work also on other IDEs, so I would had welcome separate utility for that. It seems Fat Jar is using One-JAR under its hood.
  3. Maven Assembly Plug-in – looks promising, however I had no time to get into Maven yet (shame on me). I have to try this one, this seems to be the right way to go.
  4. One-JAR – I found this one just recently and have not tried it yet. I will post my discoveries soon..

As usual, I encourage anyone who is better involved than me to share few links or hints.

Written by Samuel Kroslak

December 12, 2007 at 22:13

Posted in Java

Tagged with ,

Java Web Start under Linux

with 4 comments

I couldn’t believe it, but the whole java web start and stuff around it is just messed up on Linux platform. First, I tried to develop simple Hello world application and it worked OK. Great, I said to myself, but when I wanted to force JWS into some serious cooperation with serious ‘Hello World 2′ application, I encountered many problems there.

First – JWS under Linux has really poor tools. I mean, yes, they work, but don’t expect such a comfort as you have on MS Windows platform. No detailed information about errors if they are any. JWS simply won’t run and when I want to have some feedback, I have to run my Windows XP box and run JWS app from there to find out what’s going on.

Second – Jar signing. When you want to do something serious, you will certainly want to sign your .jar files with your deployed application. So I bundled all my application’s .jar files and .jar libraries into one .jar archive (BTW. see JPackIt which does this and it does really good job, but unfortunately has issues with JWS…this is another story) and I wanted to sign this .jar. OK, let’s Google how to do that…

keytool -genkey -keystore mykeystore {create keystore}
jarsigner -keystore mykeystore mindtermfull.jar mykey {sign jar}

That’s nice and easy, however I encountered very wild errors on my Linux box and I’m still not able to fix them.

keytool error: gnu.javax.crypto.keyring.MalformedKeyringException: MAC verification failed

If anybody has experience in signing .jars on Linux, please share you knowledge in comments. On MS Windows XP box, it went smoothly and now I have my .jar signed and can keep moving…

OS used: Debian Lenny and MS Windows XP EN Professional
JDK 6 with latest updates on both platforms

Part 2 – some good news

Niklas Mehner made some good points in comments to this post, that led me into right direction. I discovered that Java has more solid ground in Linux than I thought. First, JWS has many settings I didn’t know about and you can access it by simple command “javaws -viewer”. Second, I thought I’m using 1.6 sun jdk, but there was still GJC stuck in my system and that was why I encountered such errors. Now everything works like a charm and commands that I wrote before are working too.
Next time I will try to look at problems I encounter more deeply before blaming innocent pieces of SW in blog posts …

Written by Samuel Kroslak

December 12, 2007 at 21:21

Posted in Java, Linux

Tagged with , , ,

Debian customized installation

without comments

Introduction to customized installation of Debian distribution with KDE desktop environment on desktop/laptop. No deep knowledge of *nix OS required, but some basic knowledge is required. Let’s build a stable and high-performance OS installation in few (really) easy steps. I admit this is not complete guide how to install Debian (this is enormous task to even cover this topic), more exactly this is my way to do it. Many things here that I will state will be for sake of simplicity, so please don’t be angry if you find something ‘not quite exact’. However if you find misconceptions or anything that can help me to make this guide better, please post it in comment, thanks. (Hint> at the end of article is handy summary with files included, so you can skip all that crap if you want)

Why are we doing it? – optional reading

I’m using various linux distributions for about a 3 years now. I’m definitely NOT geek on this platform, no advanced shell scripts and that kind of stuff, I’m using linux because I like the way it works and because for me personally it is much better platform than MS Windows or Mac OS X. Of course, linux has it’s own drawbacks and disadvantages, but they – in my opinion – are acceptable for the value it gives you in return. Open source, etc.. that’s another story. I tried almost every popular distribution that is out there for last 3 years and I must admit that pure-good-old Debian is for me the winner. It is very stable and you can take advantage of HUGE ubuntu user base – most tips, tricks, scripts, etc. that are written for ubuntu are usually working on Debian too. First, I installed Debian and started to customize the installation as I worked and used it every day. Next I discovered that there is bunch of stuff I don’t need and there are also things that can do better. So I made my way through Debian jungle and made myself a little guide how to install, configure and maintain this system. Here it goes…

Choosing version, media, etc.

Debian is distributed in 3 different parallel releases – stable, testing and unstable. Read wiki for details, I choose ‘testing’, because it is not as old as ’stable’ and is not suffering with problems with ‘unstable’. Don’t worry about the name ‘testing’ – they didn’t mean it like that :>. Despite the name, it is much more stable than you think. My architecture is ‘i386′, if you don’t know what that mean, then your architecture is most probably the same. I didn’t tried 64-bit version of Debian yet and I think it’s not worth it – definitely not for desktop/laptop that you are using for your common day-to-day needs. I once tried to run 64-bit Kubuntu linux and it was everyday struggle with almost all applications that I encountered (not every application is 64-bit ready, and those which claim they are, they are sometimes not too). So keep 64-bit version for server usage just for a few moments until things settle up a little bit.

Not only Debian comes in different releases, it also comes in different installation methods. I chose net install, which is best way, if you have serious Internet connection and you want to set things up your way. But to install it this way, you need to know exactly which packages do you need and thus this is is best installation method if you already worked with Debian (or Debian based distro like ubuntu, mint, kubuntu, etc) before. Or you can download LiveCD of debian and try what things/features you like and then proceed to this type of installation. Don’t hurry, you can install clean OS and play with packages later. Get yourself a suitable installation media – search for net install CD. Debian is very universal OS, so Debian official website can be really confusing sometimes. Navigate directly to page http://www.debian.org/devel/debian-installer/ and find line of links with this title>

netinst (generally 135-175 MB) and businesscard (generally 20-50 MB) CD images

choose your architecture (i386) and download ‘debian-testing-i386-netinst.iso’. Burn (or mount if you are using VM) and you are good to go.

Installation

Assuming that you have installation medium ready, we can boot from it and start installation. Just for now, keep everything you don’t need to change (or don’t understand) at default and proceed through steps. Just pretend you are installing Windows XP and clicking on Next> button :>. We will stop at the point “Debian software selection”, where you can choose packages you want to install.
Debian software selection dialog.

Make sure only to check “basic system” nothing more. No desktop environment, nothing like that. Now go through the rest of installation. (sorry for that ugly picture, I will try to make better one next time…)

Installation of desktop enviroment

Nothing fancy. After first stage of installation we ended up with plain command line, that’s what we wanted :>. Now we are going to add required repositories to be able to install KDE environment>

nano /etc/apt/sources.list

will open up file with our repositories, just add strings ‘contrib non-free’ at the end of every line, so the ’sources.list’ file will look like the one in resources at the bottom of article. Then fire commands>

apt-get update
apt-get install x-window-system kdebase kdm

This will ensure that KDE desktop enviroment will be installed correctly AND it will be clean core KDE desktop environment, not that KDE default installation which comes by default and is (in my opinion) overloaded with application that you will rarely use. That’s it, we are quite finished with installation. In my case I had to reconfigure X system, because my nVidia laptop video card wasn’t working correctly (she was refusing to set correct resolution). You will reconfigure X with command>

dpkg-reconfigure xserver-xfree86

When you will be asked for video driver and you have nVidia, choose ‘nv’.

Summary and my files

1, download Debian net install CD from ‘testing’ release and burn
2, boot and install with default options, when you encounter ‘Debian software selection’, choose only ‘base system’
3, edit /etc/apt/sources.list and add non-free and contrib repositories
4, apt-get update; apt-get install x-window-system kdebase kdm
5, after restart, dpkg-reconfigure xserver-xfree86 if needed
Files for your inspiration> sources.list apt-getInstall.sh

All for now, any comments for improvement of this how-to?

Written by Samuel Kroslak

December 9, 2007 at 20:24

Posted in Linux

Tagged with ,

Vancouver’s first eclipse demo camp

without comments

I attended first eclipse demo camp in downtown Vancouver. Great experience, friendly and open people including presenters and organizators. Everything went smoothly and in well organized manner. There are some highlights that actualy woke me up (in order of my personal interest):

  • Tasktop – Bright example of how much power Mylyn brought to eclipse. Very ambitious project that could be one day my personal manager. Integration of web browser and file manager and lots of stuff around made good impression on me. I personaly still can’t imagine to give up firefox and Krusader file manager, but who knows :>. Make sure you don’t miss that one.
  • Embedded CAL – Embedded functional language inside java source code? That’s not bad idea at all. Check out their web site and you will be surprised how far did they push it!
  • Fishtail – Sure, guys from UBC are not sleeping at all. Eclipse plugin that is expert in finding “how-to” type of information about source code stuff. Nice
  • Nomad PIM – Eclipse RCP based personal information manager. From website of author: “It allows you to keep track of your personal data and currently provides modules for notes, schedule, contacts, money, diary and timetracking.” Seems very promising too. I like it.

Here you can find official page of this demo camp with details: wiki.eclipse.org/Vancouver_DemoCamp
There was also a social event after presentation which was very nice and there was a lot of room for discussion about anything between people from various industries and professions. Any comments about my spelling are welcome :>

Written by Samuel Kroslak

December 9, 2007 at 08:12

Posted in Java

Tagged with ,