Skip navigation.

exploreopera

| Help

Sign up | Help

photo

Vaclav's not-often-used blog

working on cool projects

Posts tagged with "java"

Switch: Week 1

, , , ...

Hello, from the Mac for the first time. I would like to share some experiences with you about my switch to Mac. Before buying my MacBook Pro I thought of posting several (like 10+) episodes about switching and problems I had to solve and thing I discover. However the switch was so fast and painless for that there is in fact not so much to write about. As well it makes almost no sense to list all what I discover as there really tons of small and big great features all over the system. I recommend to watch some of them at Apple Video Tutorials.

Why I switched?
There are several reasons why I switched right now. I planned my next computer to be Mac for quite a long time. I used Windows XP for very long time (since its release) and had an opportunity to use Vista on my brother's computer for about 2 months when he went to England for a while leaving his notebook at home. And I must say I was happy to return back to Windows XP. Vista felt simply like developer preview, not like something that should reach paying customers. As I see around me at the university only fans of MS have Vista installed. These are the guys considering 5 years old features high-tech just because they are aware of MS products and don't usually know anything about where the technology really is.

Let's sum it up:
  • overall user interface of Mac OS X
  • Spotlight, Time MAchine, FileVault, Dock, FInder, ...
  • iLife
  • terrible user experince with Windows Vista
  • I had a very good desktop computer, but I needed a good notebook too
  • Windows XP having almost no built-in useful features
  • in the worst case scenario I can just install Windows

Why I didn't want to switch
I'm primarily a Java developer and I already use Java 1.6 in some projects. In fact I don't like Apple for many reasons, but I really hate its silence about when Java 1.6 will be released on Mac OS X. Although Apple doesn't talk about future product releases, I guess there is no real reason why not to let developers know. Development of Java is open and everybody knows how Java 1.6 looks like as it's for long time available for Linux, Solaris and Windows. Apple (Steve Jobs) promised that Mac OS X will be a premier platform for Java development when they were desperate to attract developers to their platform which was almost extinct at that time.

Let's sum it up:
  • only developer preview of Java 1.6
  • same things will probably occur also with Java 1.7 and others
  • higher price (especially in the Czech Republic the prices are much higher than those in USA and much higher than competition)

The switch cost
Well, the switch cost was surprisingly low. In fact I got the MacBook Pro at Saturday evening and in Sunday I had all current data transfered, organized photos in iPhoto, music in iTunes, movies in iMovie, developing Java projects in IntelliJ IDEA, continuing my diploma thesis in NeoOffice, preparing presentation in iWork and almost ready my first DVD with iDVD. There are still some data on backup DVDs I have to put on my MacBook, but I would like filter them and reorganize them which is really boring and I don't it right now.
I don't expect that everybody's switch will be so smooth. I guess it probably depends how much has Microsoft locked you to its closed technologies, how many legacy non-crossplatform you use, how much you play games etc. For me as Java developer using primarily IDE, OpenOffice and Photoshop (just for personal use) the switch was like a charm. The problem is however that for example Adobe has separate Mc and Windows versions of their products, so you have to re-buy what you already have. Fortunately there is a student edition of their packages which are really affordable.

The difference
I have to say I had already known something about Mac OS X prior buying it. I have played with it several times and also know something about the technology. However I was shocked how different Mac OS X and Windows really are. Windows looks like a framework to start building an usable work environment, while Mac OS X is well usable from the very beginning. I won't compare them here as from my point view the products are in vastly different class and categories.

Pros and Cons
I won't write much about this as you could write a book about it. The overall experience is incredibly positive. I finally understand why Apple has so strong customer base. There is simply no way back. But it's not made the Microsoft's way to lock you on their technologies/formats/protocols. It's simply done by user interface and user experience.

The only really bad news for me was that you can't use FileVault (home folder encryption) and Time Machine (backup) in the way it's advertised. Your data are backed up only when you log out and you can't use the cool Time Machine interface. So you have to choose between security with weaker backup experience or no security with all the Time Machine features. I have chosen the first one as data protection on a notebook is essential for me and I don't expect I will return often to older versions of my data. The problem is caused by the way data are encrypted and seems to be by-design, so I will have to wait at least until Mac OS X 10.6. Maybe ZFS might help with this.

I'm most impressed by results you get from iLife and iWork. With much less effort than in any software on Windows you get extremely good looking results - document, presentations, movies, DVDs, slideshows etc. The Windows-made stuff looks like being made by 5 years old retarded child compared what an average user can do on Mac. Another great feature is organization of photos to events in iPhoto. I won't write more as I would simply waste hours writing what I like about Mac OS X and software on it.

You have to try to know what Mac OS X is all about. When you read the feature list it maybe doesn't look much better than any other OS, but when you try it you will see that every point in the feature list helps you a lot and there are many things not listed. Can't be told, can't be shown, must be experienced.

Hardware Cons:
  • lid does not touch the bottom part of notebook in the corners
  • exchanging hard drive can be quite a challenge :smile:
  • really hot when encoding video

Hardware Pros:
  • LED backlight
  • GeForce M8600
  • touchpad
  • size
  • aluminum enclosure
  • great keyboard + illumination
  • magnetic power cord
  • adapter size and roller solver
  • remote control
  • slot-in DVD drive
  • 6-pin FireWire 400 and FireWire 800
  • dual-link DVI
  • WiFi draft n
  • minimalist functional design

Software Cons:
  • not final Java 1.6
  • can't use combination of FIleVault + TimeMachine in the advertised way
  • had to restart twice, because the system simply got very slow and I was unable to determine why
  • failed to wake-up when the lid was closed in Front Row

Software Pros:
  • easy to setup Mac OS X
  • overall usability and look-and-feel
  • great looking results in iLife and iWork with minimal effort
  • Spotlight, FileVault, FInder (Sharing), Dock (Stacks), ...
  • ... to long to write - you have to try it :smile:

Conclusion
The only bright side about Windows is that I don't have to use them any more. If you play games, Mac should not be your choice. If you want to create something starting from presentation, programming to making movies choose Mac, because Windows is really something that limits your potential and wastes your time. That makes Windows much more expensive than any Apple hardware. I wish I have done the switch sooner.

Java 7 - YES and NO

, , , ...

A lot of people migrate to Java from various languages and they bring to Java their ideas how the language should look like. I switched to Java several years ago from C++ and also thought there is something missing in Java. I missed the overloaded operators and some other things. But after few months I no longer missed them and even wouldn't like them to be included in Java.

This migration leads to many suggestions how to "improve" Java language in many different ways. So I would like publish series of posts that explain how I feel about the changes proposed for Java 7. Why I think they are good or bad. And think over whether the features can be done in a better way (from my point of view of course).

I plan to write about these "issues":
  • Closures
  • Properties
  • Enhanced try-catch-finally
  • Super packages (JSR 294)
  • Java Module System (JSR 277)
  • Swing Application Framework (JSR 296)
  • Beans Binding (JSR 295)
  • Beans Validation (JSR 303)
  • Units and Quantities (JSR 275)
  • JVM level changes
  • what I miss in Java 7

If you feel there is also something else I should write about, let me know.

My First Lecture

, , , ...

So, I devilered my very first lecture at CTU in Prague (Czech Technical University in Prague). I talked about a project I'm developing as my diploma thesis - Java Object Database. The main focus of the lecture was on problems objects databases are facing, how they can be solved and what approaches can be used to make persistence easy-to-use, reliable and fast in the same time.

I believe the lecture was interesting for anyone who is currently using ORM, JPA, Hibernate, relational databases etc. You can download a copy of presentation below this post. Although the slides were created to be accompanied with commentary, you can still find interesting information in them. If you have any questions or ideas, don't hesitate to contact me.

I will write soon a post describing the database in more detail, so stay tuned. If you want something specific to be explained, let me know and I'll try my best.

English in OpenDocument
English in MS PowerPoint
English in PDF (no animations)

Česky v OpenDocument
Česky v MS PowerPoint
Česky v PDF (bez animací)

IntelliJ IDEA 8 - Preview

, , ,

IntelliJ IDEA 8 early access version codenamed Diana is available for download and testing. From my point of view IntelliJ IDEA is the best IDE on the market. Although NetBeans has made tremendous step forward in version 6.0, IDEA is still somehow easier to use, more intuitive with powerful features at your fingertips.

For those who don't know IntelliJ IDEA the best way to describe its advantages is to recommend trial download or reading features. My favorite features are really robust refactoring, code inspections, TeamCity integration and overall ease-of-use. What I miss most is a profiler similar to the available in Netbeans by default. When I spoke with a JetBrains developer I was told that profiler is not planned as it's not requested by many people and it's relatively hard to implement. So if you want a profiler keep JetBrains asking for it.

Alhough there is nothing really interesting for me in this early version (as I don't use the newly supported technologies) you may find them useful:
  • Seam support (inspections, code completion, pageflow designer)
  • FreeMarker support
  • JavaScript debugger
  • SQL support (multiple dialects for detecting for features supported by different databases)
  • Flex support (including debugging)
  • Struts 2 plugin included by default
  • Many incremental changes

My personal wishlist would be:
  • Profiler
  • Built-in Android support
  • Free academic license (as using IDEA in classroom for free and forcing students to buy a license doesn't seem right to me)

IntelliJ IDEA 8 EAP Release Notes
IntelliJ IDEA 8 EAP Download page

Poweful 3D Egnine for Java

, , , ...

Have you ever thought of creating a 3D game? There is an Java engine that could help you and the best I have found so far - jMonkeyEngine. jMonkeyEngine is used already in several commercial games. Stable 1.0 version is available and 2.0 is currently under development.

If you are in doubts whether jMonkeyEngine is good enough for you, you should probably know that Sun has chosen it for Project Wonderland. The project is focused on creating online 3D collaborative environments. So you can be sure that jMonkeyEngine has a bright future with Sun in the background.

It was never so easy to create a game. No C-family language programming torture. Smooth running on every platform and even in browser. You won't probably compete with graphics of latest AAA titles, but you can get pretty good results - see screenshots. Also games are not only about graphics, right?

On the official site you will find a lot of resources, tutorials and forums to help you start. It won't take long and you will get first results rendered on your display. Except rendering 3D jMonkeyEngine also provides support for simple game logic, sound, user input and some other stuff related to creating computer games.

You can also expect that jMonkeyEngine will make it to Google Android as it supports OpenGL ES. See Joshua's Blog for more details about this effort.

Some features chosen from jMonkeyEngine website:
  • Java Applet and SWING support
  • Fast and compact jME binary format
  • Extensible to allow other import/export formats (XML is planned)
  • All geometry can be enclosed in a bounding system - Boxes, Capsules and Spheres
  • Bezier curves can be used for node controlling
  • Bezier Mesh - For smooth curved surfaces
  • Effects - GLSL Shader Support
  • High Quality Water with configurable reflection, refraction, wave generation, etc.
  • Extensible Particle System
  • Lens Flare, Screen tinting
  • Cloth Simulation
  • Textures in BMP, uncompressed TGA, JPG, PNG, GIF, DDS
  • Textures support mipmapping, environmental mapping, multitexturing
  • Collision and Picking
  • Lighting - Supports directional light, spot light and point light
  • Z-Pass Shadow Volumes
  • Continuous Level of Detail dynamically collapses triangles of a single model
  • Model Loading - COLLADA, 3DS, Obj, MD2, MD3, Milkshape, ASE support
  • Supports skin and bones and weighted skeletal animation
  • Render to texture
  • User Input System
  • Supports OpenAL and FMOD
  • ... more

JNode version 0.2.6

, , , ...

JNode is a Java operating system with very small assembler nano-kernel. Unfortunately I have not much time recently, so I can't help JNode developers to improve the system. But at least I will try to make a little advertisement here. JNode is now in version 0.2.6 with these cool features:
  • 99% Java 6 compatibility
  • HFS+ support
  • more OpenJDK integration
  • bug fixes and improvements

If you want to help developing the next generation operating system, visit jnode.org. I hope they will make it into Google Summer of Code 2008 so you could get paid for help. There are many areas you can help including but not limited to writing documentation, improving GC, writing 3D drivers, improving interface.

Class loading in Java and C# (RFOB)

, , , ...

Java and C# are often told to be almost identical languages. C# is often being accused of being just a remake of Java. I would like to show some very core difference between how things work in Java and C#. Of course Java and C# are competitors despite their differences as C++, PHP, Objective-C, Python and others are also competitors of Java in specific areas of programming.
I would like to excuse a bit for not havingdeep knowledge of C#. So if find something that you think is wrong let me know. I describe here the difference I have discovered during some project I'm working on for some time. I wouldn't like to talk about this project to wide public yet, but some of my friends already know and this blog will be probably the first place I'll write about this cool project.

History

The process of executing code has evolved over the years. Starting with just machine-code being executed from the specified location. Dynamic libraries came later - these are the .dll, .so and other stuff you know from any operating system. Major advantage of dynamic libraries is that not all code has to me included in the programm itself. This mechanism is used from 80's to date. The special category of class execution are scripting languages. Applications in scipting languages usually came as a collection of text files that are executed when you open them or access them from the internet (JavaScript, PHP and a lot of others). The major advantage is that these scripts are human-readable can be modified anytime including right before execution (in extreme cases also during the execution by the application itself - but please do not do this at home without suprvision of adult person as it leads to producing VERY MESSY code).
When Java came it brought revolutionary new mechanism of loading new code. This was called dynamic class loading. The idea was great - the application can load any class from any location including but not limited to local file-system, internet server, SQL database etc. However this feature is not used very often in Java.

C#'s approach

Well, in fact, there is nothing what to write about. The C# is not much different from any other C-family language. Although it uses syntax similar to Java and has garbage collection in runtime it still behaves much like any older language.
C# in fact doesn't load classes. Instead it loads so called "asseblies" which are in fact several classes group together. I'm not sure whether the assembly is a whole .dll, but I think it's not. However this is not so important. I don't also know why the classes are not loaded separately but it can be bacause of performance reasons and the fact that the object-oriented design is partialy sacrificed after compilation to CIL. This enables non-virtual method calls that cannot be used in Java and probably other optimization enabled by the fact that the classes are not strictly separated and "know more" about each-other.
The most important difference is that all code in C# is loaded by system. The application has no option to take care of the class loading. This enables that compiled code of .dll can be cached and the .dll doesn't have to be compiled from CIL to machine code every time the application runs.
I don't know why Microsoft has chosen this approach, but reasons are probably three:
  • C# is more C++ than Java and compability with C++ requires using .dlls and loading in assemblies
  • performance reasons - enable caching of compiled code, enable non-virtual method call etc.
  • Microsoft in general is known for poor architecture of it's applications and Java-like class loading could be just a thing that wasn't considered important


Java approach

Although Java is older than C# it uses much more advanced aproach as it doesn't have a heritage of older languages and was designed from the ground without compatibility with any other language.
The class loading process in Java is pretty simple, flexible and can be customized by developer. The key to class loading is surprisingly class called ClassLoader. This class is abstract and can be extended by developer. Class loaders are structured into a hierarchy with root class loader being so-called system class loader. If you don't use your own class loader the system class loader usually does all the stuff.
So what is the purpose of class loaders? Their name explains it pretty clearly, doesn't it? But to be sure here are the things system class loader does:
  1. locates byte-code of classes
  2. locates resources (.properties files, image files and whatever else in your .jar archives)
    passes byte-code of classes to JVM

So what's the great thing about that? Almost every language can load files and code dynamically. The great thing is that you can override all these methods :-). You still don't know what is so great about it? The great think is that you can load the classes from anywhere (for example download from IMAP acount if you are really crazy) and can do anything with the byte-code before you pass it to the JVM.

So, is there any practical use for that? I think you think that I can't think seriously you would think that this example would make think that class loading in Java is extra useful. Except the project I'm currenty working on , which would be impossible without custom class loading, there are few examples I can think of:
  • you can your classes store encrypted (when used on untrusted server) and decrypt them in runtime
  • you can instrument the code for collecting statistics (for example number of method calls etc.)
  • you can download classes of specified version directly from Subversion
  • you can optimize byte-code and cache it
  • you can generate custom classes in your class loader

And how to create custom class loader? Well, use the Javadoc and your fantasy. It's really long story to tell all what you you can do and how. When starting with Javadoc try ClassLoader.loadClass(String) method first and follow all related to it :-).

But I will tell a short story now. What you can't do with custom class loader?
  • you can't load classes in package java.*
  • you can't make custom compilation of byte-code to machine code (however you can optimize byte-code before passing it to JVM if you feel good enough :-))

And one last thing. Remember that MyClass loaded by class loader A is not compatible with MyClass loaded with class loader B although the classes are exactly the same.

Ufff. That was interesting. Let me know if you understand the post or not. I will have to fix it few times probably before making it clear enough.

JNode - the future of OS?

, , , ...

Well, as I see this is the first post after one whole year :smile: OK, let's attempt for the second time to start a blog.

This post will be a little technical indeed and I will probably write few other technical posts over time as I consider them more interesting/useful than soap opera of my life. I thing there is enough blogs about personal life and I would probably just repeat the same stories with sligtly different names and places. But I could try some such stuff occasionaly.

So, back to the title.

When you think of an operating system you usually know MacOS X, Windows and probably Linux. More interested people probably know about Solaris (technologicaly probably most advanced OS), FreeBSD and similar. But I guess almost none of you heard about JNode.

JNode is very interesting OS writen mostly in Java. From what I know there is just an assembler nano-kernel, which is about 15 short assembler files. Purpose of the nano-kernel is to initialize JVM and provide low level operations such as moving blocks of data from one location to another.

The most important is that everything else is in Java. So when you hear something like "C/C++ is the only language for system-level programming", you hear something that is not true. JNode's JVM is itself written in Java as well as device drivers and everything else except the nano-kernel.

So what is the advantage of using Java for an OS? Let's list some:
  • Language Level Security
  • simple migration to different processors - just rewrite nano-kernel and provide JIT compilator for JVM, no rewriting of applications and even the rest of operating system
  • single JVM for all programs - lower memory usage, no startup overhead
  • robust and simple to setup security ensured by Java Permissions
  • no pointers rovering thorough the OS - no memory leaks, buffer overflow etc.
  • Java has by far the best developer tools available (IntelliJ IDEA especially - my favorite)
  • ... a lot more


So what about the JNode? Well JNode is just a beginning that shows the way. If you are interested you would probably like to visit jnode.org. You can find some screenshots there or download an image of the OS to try it on your PC.


As you will see, there is a lot to be done yet. So if you are interested join JNode developers on IRC and they will answer your questions and help to start developing. Remmember that JNode community doesn't look just for Java programmers, but also for people who would help with web, documentation, testing and whatever you can think of.

So how does compare JNode to a Linux? JNode is much younger, based on design patterns and object oriented from the ground. JNode uses extremely small nano-kernel containing thousands of lines of code, compared to millions in Linux kernel. JNode uses LGPL licence instead of the GPL used in Linux, which makes it more suitable even for commercial use in the future. But Linux is stable and fully working OS, while JNode is still under heavy development.

If you want to shape the future of operating system, give JNode a try and help others develop this system. If you have any questions feel free to post them in comments. If you are more interested in something specific in JNode, let me know.

JNode website
My JNode logo proporsal

All the good stuff

, ,

So it's pretty long time since I wrote my last post. I guess nobody would read them anyway, so it doesn't matter much.

Since my last time a lot of things changed. I finished first part of my school and become a bachelor. Since then I almost forget to study and I almost haven't visited school, so this exams time is going to be pretty interesting yet.
However I have very good exam in physics, that I started to hate several years ago while encountering it for the first time at uni. Fortunately I had a pretty cool professor this semester (Petr Kulhanek), so no "try-to-remember-as-much-as-possible-exam" is necessary, just to write single applet demonstrating you are able to work with physics in real life. The image lower is result of my friend's and my work. Single Java product working as both applet and standalone application.
I also really tried CVS for the first time and it was quite a great experience with Tomas Prochazka who is the second author of the application. Great idea and code exchange. His programming style is quite close to mine and he understands Java as well as I do (hard to tell and not important to tell who is better). So, I say virtual "Thank You" to Tomas. Pretty good change from last time I used to work on another programmer's code.


Another good experience was subject "Human-Computer Interaction" when I designed a whole new keyboard with unique features and performed usability tests on friends which was a great fun. I also patented the keyboard and sent it to some cell-phone manufacturers. Till now I got only "negative" feedback and I'll make public some answers I got as soon as I get some more :smile:. Some of them are really funny. I also plan to make public the keyboard to let you see what it was all about.

I'm also trying to join a project I2Home focused on bringing computers to home. To control you daily life and to serve you. The group here in the Czech Republic is focused on seniors and I'm looking forward to bring some cool ideas to the project. Seem to me that there are pretty nice people I met in subject "Human-Computer Interaction".

And the final and greatest thing I unfortunately can't talk much about. So I only say: It's interesting, it's in Java and I enjoy creating it. I'll try as fast as I can to bring some stuff to public as soon as possible.

Thanks for reading.
September 2008
SMTWTFS
August 2008October 2008
123456
78910111213
14151617181920
21222324252627
282930