Showing posts with label swing. Show all posts
Showing posts with label swing. Show all posts

Friday, June 03, 2016

Old projects reborn - MoneyTimer

This is another tool, I've tried to update in order to withstand the test of time - MoneyTimer

What does it do ?
It measures time and calculates every second how much time it costed all participants.
Great for consultation meetings!



You can try out the latest release here:

What I can learn from it?
- Java 8 Lambda expressions
- Simple Multi-threaded application
- Swing

How to contribute: 
Check the instructions at the github repo page.
If you are wondering what to contribute: there's a list of ideas in the issues page


Tune in, because more complex ones are coming ...

PS:
Check out my other project that can interest you. This time about HTML generation via XSL transformations - http://javamissionary.blogspot.bg/2016/04/old-projects-reborn-filesystem2html-tool.html

Wednesday, September 01, 2010

JDK 7 new features (part 1)

Hi there,

We all know Java. Many love it, some dislike it, other actually hate it... and if they knew its weaknesses and flaws as I know some of them, well, they'd pity all the Java developers for choosing such a fragile platform and language...

 So basically , before you thought I hate Java, the thruth is just the opposite - check this blog's name :) - but I admit that Java has some veeeery bad treats and design flaws.

But why am I talking about Java flaws in a posting called "Java 7 new features" -- well , because they(the guys behind Java) try to address some of these problems , I'm also going to point some of them to you..

 
This list is not ordered by me - everywhere I look these features are presented in this order. I'll keep it that way for consistency.

Feature: 64/32 bit pointers support 
-- why store 32bit pointers in 64bit space, when you don't need it. The JVM will be more agile and not create empty spaces in the pointers, so less space will be required, which will help the traffic more than a local system with gigabytes of RAM. Performance boost.

Feature: Garbage-first Garbage Collection
- kills the young fast-dying generation first. and preserves objects that have survived the wipe a few times.
Result: more GC options and strategies -- performance boost.


Feature: dynamic languages in JVM
-- All can agree that Dynamic languages have big future ahead of them and that's a good reason that Java should try to adopt them and try to run them natively on a JVM. Thus making the JVM something like a universal VM for different kinds of languages. Imagine the freedom to combine different languages and techniques easily with native support and not some simulators.... no performance problems ... no interoperability problems... I really hope this is going to be implemented very professionally.

Added support for lambda functions, which could revolutionize some known patterns in the Java world - creation of an anonymous class for an interface like MouseListener and so on - now you can create a lambda implementation, pass it as an argument and inside it can be executed. This will make our Java a more interesting place. The anonymous-class design that was being forced because of the lack of such a feature and it's not intuitive at all. Let's see where this will get us.

Feature: Java modularity - Project Jigsaw
This project, in my opinion, will be an improvement, which will improve our Java experience. But what exactly is the problem? What do you mean with "Java modularity" ? Java is already modular, some will say... Well, it isn't.

Just check your local JRE installation and see in the \lib\  directory the rt.jar (rt = runtime). Notice the size - using latest JDK 1.6 Update 21, the rt.jar is around 47 MB.

Yeah, 47 MB and that's a module... yeah right. Nice design, guys! Many classes must be written with lots of lines to fill those 47 MB and believe me - these 47MB in rt.jar are all classes. Who wants to say how many millions of code...

But why when I only use java.net and java.lang should my JVM also load SWING and java.beans and javax.xml ... The sad reason is that all of them are all TIGHTLY coupled...

Somehow, somebody let it all loose control and everybody started pushing shit in this .jar file... well it works, so who cares? It's not modular... again, who cares? You can't easily extract a piece of it and place it elsewhere. You can't manage your JVM RAM requirements because of required modules being all stick together and you can't separate them.

Image that you can modify your JVM depending on your business case !
Well, project JIGSAW is trying to solve exactly this problem - separating all swing, applet etc modules into separate sub-projects and decomponentizing the  rt.jar into several (hundred?) jar files.

I imagine something like a ( JVM + OSGi ) ... yeah :)

I wish the developers good luck, because of the issues that could arise, and I think it's not a trivial job.
Remember they also have to maintain the backwards operability somehow...

...
I see that this post has become very long, so I'm going to continue it later.

Feel free to comment, because my view on a topic could be very wrong, but I'd love if you start a discussion. Especially when the topic is Java :)

Leni Kirilov

Saturday, August 28, 2010

Java 5 and Java 6 not so popular features set

Many know about generics, collections enhancements and auto-boxing, varargs, annotations ,but there are some less popular features added to java in Java5 and Java6. I'm going to point the lights on them, because they are little treasures:

Java 5:


- Formatter class - easy to use class for proper formatting of numbers, date-time, currency etc

- Scanner class - slower but comfortable to use to read text from streams

-    java.util.concurrency.* package - atomic classes introduced. You are going to use them if you are in a concurrent environment... Also locks and some thread-safe collections

- JMX was added to J2SE --- instrumentation, management for your applications, MBeans - you name it

- Arrays.fill() -- fills an array with a value you give it. Very useful instead of writing a loop and doing it manually.

- Arrays.deepToString(); --- another great static method -- instead of writing a recursion method to print the toString method of the elements in a multi-dimensional array, you just use this method !

- JTable printing - it looks more natural to have a native printing method



Java 6:

-  Deque --double-ended queue was added as an interface in the collections package

- int[] newArray = Arrays.copyOf(anotherArray, newLength);  --- faster and cooler than System.arraycopy(..)

- drag'n'drop improved --- they made it more usable, but how exactly - I haven't tried it to tell you

- JTable sorting and filtering added

- Console class added

- new methods in File - getTotalSpace(), getFreeSpace(), getUsableSpace() --- why create a file and fill it with some data when you can first check if there is enough space in the drive to create the file in the first place?

- java.util.zip.DeflaterInputStream: Data read from this stream is compressed.
  java.util.zip.InflaterOutputStream: Data written to this stream is decompressed.

Or in normal human language - something like a Zip Streams where data is compressed . Nice! I am sure to use it next time!

- JMX was greatly fixed and update so my suggestion is to use it on this JRE6 version.

- JSR 223: Scripting for the Java™ Platform API -- This is a framework by which Java Applications can "host" script engines


So Java guys, out there, don't miss out these features and have in mind the enhancements :)

L.K.

Wednesday, May 19, 2010

NetBeans 6.8 bugs

Today I'll comment my favourite IDE for Java development - NetBeans.

Some may say that I'm a newbie and like less complicated IDE or that "true Java developers" use Eclipse - OK so be it, but I'm working on Eclipse at work and at home I'm using whatever I feel like using and NetBeans is what I like using!

So I've recently found a few bugs while developing a small application.

1. Swing forms editor bug

NetBeans is popular with its very well-made Swing UI editor and I agree with common understandings. UI forms are easy to use, can be configured in lots of ways (some of which I haven't tried yet), but satisfies my needs completely. It generates some code and locks it , so that future UI replacement/movements are still consistent with the rest of the class you are managing. Easy event handling methods and so on...

But I've had a few places I wanted to manipulate and configure the initialization of the components. NetBeans automatically creates a constructor with "init();" method call in it , but my case required to modify this init() method.

So you can click on the JComponent and click "Customize code" , which lets you modify the constructor called but not the declaration! I found this very restrictive and tried to trick NetBeans.

I had to change the place of a class from package "a" to package "b", but if I cannot change the declaration, I'm stuck. So I decided to use REFACTOR rename on the package of the problematic class. And it worked! ...
at first...

I refactored the name of the package and no problem in the UI created code.
But if you try to move 1 pixel of the UI form , it regenerates again the locked code and refreshes the metainf. xml in the netbeans project and my IDE shows an error of non-existing class/package...

I'm going to report this and get it fixed in NetBeans 6.9.

2. Main class in built .jar is missing

The next major bug I've found is already reported. I even reached the helpful guys in www.stackoverflow.com
You can find my question here ->  Main class in NetBeans bug

I'll rewrite the short description here:

You create a Java project in NetBeans 6.8 or 6.9 and build it to create a .jar file.
Even if you have set in the project settings which class contains the main() method to be executed, the build omits this configuration in the meta-inf/manifest file  after build and so the .jar is not executable.

This is easily fixed by :
- creating a metainf.mf file in root of your project
- the file contains something like

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 16.3-b01 (Sun Microsystems Inc.)
Main-Class: com.example.MainClass
Class-Path: lib/lib1.jar lib/lib2.jar


- editing the nbproject/project.properties  file
- add manifest.file=manifest.mf
- save and rebuild

This solved my problem and thanks a lot to the NetBeans and stackoverflow society so quickly.

L.K.