Trivia question – “Finally”

Here is a confusing question – what does the next code prints? public static void doStam() { try { doExcption(); return; } finally { System.out.println(“Finally”); } } public static void main(String[] args) { doStam(); } public static void doExcption() { String [] stam = new String[0]; //purpose exception stam[1].toString(); } Answer: Finally Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: …

Apache Pivot. Making Java GUI is easy.

I just got to know to Pivot and I have to say, I love it. Pivot is a technology to create Java applets for RIA or desktop applications with the use of XML and/or code. When I write applications at home I don’t want waste time writing swing or applets myself. Pivot helps me designing the GUI with use of XML. It is that simple and the cool thing is that you can run it as a web page and a desktop application. An example of a Pivot XML (WTKX): After creating the XML, you can refer to the GUI components from the code. Actually the entire GUI can be built just from the code, but I like the XML way better. The application can be run from the IDE or can be referred from a web page as an applet. All you have to do is refer to the Pivot jars + your jar and give the full name of your application class you have created. The result: The Pivot web site contains loads of examples with the use of their components. download sample project for Eclipse but don’t forget also to download Pivot jars. See also Pivot website Continue reading Apache Pivot. Making Java GUI is easy.

Java Interface rules

Let’s start with a short Java question: Bellow you can see the interface ‘Test’. Which lines in that interface will be rejected by the compiler? The answer is: lines: 7,8,9,10 I am sure that even many of the experienced java developers will not have a 100% success answering this question because it can be confusing. 1, 2, 3 and 4 are actually all the same – only constants are allowed and by default they are. For that reason, 10 is not allowed. 5, 6 are the same – only public and protected methods are allowed. By default they are public. In short these are the rules for interfaces: Member variables Can be only public and are by default. By default are static and always static By default are final and always final Methods Can be only public and are by default. Can NOT be static Can Not be Final

Weekend project: Bluetooth multisender

In my last post I have shown you how to communicate with Bluetooth devices using java + Bluecove.jar. Using this knowledge I have created this small java weekend project – Bluetooth multisender. This program will scan for Bluetooth devices in the area. For each Bluetooth device found, it will check whether it can receives text messages. Each supported device will be added to the list on the left. All you need to do is selected device/s, write a message and press the send button. The message will be sent to all selected devices at once. Yeh, I know it’s not the nicest looking gui there is, but it’s working 🙂 download project View on github