## Extending Java / RAD Support with NetBeans

In This Posting, I wrote that Java / RAD – ie Swing – Support could be added to the free version of Eclipse.

Well as a follow-up, I just wanted to mention that the Window Builder that this procedure installed, is not extensible. This can be quite limiting.

Instead, a better approach might be to install “Net Beans“, even under Linux. This IDE will support OpenJDK 7. We do need to make sure though, that we do not only have the JRE package installed, but also the JDK (development) package. It is a bit harder to set up than the other one, but has as advantage a Component Palette which is extensible.

After installing Net Beans, the thing to do is to add some sort of standard, built-in Swing component, thereby making the Component Palette visible in the IDE. We have our Swing Designer at that point. Then, under Linux, it is possible to add the Jar File ‘/usr/share/java/swingx.jar‘ to Net Beans, by way of ‘Tools -> Libraries (Global Libraries)’. Then, we can right-click on the Project and click on ‘Properties -> Libraries’, and add the newly-defined Library to the Project.

Next, we can right-click on the component palette, and open the Palette Manager, from which we first create a new Component Category. It will be empty. Then, still within the Palette Manager, we can add components at will From the newly defined Library. It will ask us which Category to add them to, and presumably we would add them to the Category we just created.

And at that point we will see, that we not only have components such as “JPanel”, but that we potentially have a large number of components, whose names begin with “JX”, such as “JXPanel” …

I never really knew, that Net Beans was so powerful, yet free. However, Net Beans is not open source, and to install it, we need to run their SH File as ‘root’. This could present a daunting leap of trust for some people. Also, even though this setup script wants to be run in root mode, it will also need to display a graphical wizard. This requirement has led to a common but minor error message with many users. And so, in user mode, we need to give the command ‘xhost +‘ first, so that the root-mode process can access our X-server, and then after we have installed Net Beans, back in user mode, we give the command ‘xhost -‘ again.

## Getting Java / RAD support within the Open version of Eclipse

One type of question which some of my friends will ask me from time to time, is ‘Whether I am aware of any good IDEs these days’. This question arises from the knowledge, that writing source code just with a text editor, is not much fun, the fact that IDEs exist which enhance the programming experience, and finally, the memory from our distant past, of the fact that there exist IDEs which implement a kind of ‘RAD’ – a Rational Application Development – or a Rapid Application Development platform. This can sometimes conjure up pleasant memories of the days when Sun Microsystems was still in control of Java.

And so I have taken a minor step to explore this subject only today, and come to the following observations.

Java / RAD in the old days, was already based on ‘Swing‘. And Swing is a set of Java packages, which keep two things in sync: A code view, and a design view of our project. It was Swing which would update the code view, if we made changes graphically to our design view, and vice-versa.

Having understood that, the next thing people who use Linux might do – as I did – would be to install a number of Java Swing libraries from our package manager, and then to hope that we have what it takes to start building Java / RAD projects, the way we used to do it with ‘JBuilder‘. JBuilder was a proprietary, paid-for IDE, which back in the days of ‘Borland Inprise‘, possessed the components in a bundled way, not just to be an IDE, but to be an IDE with RAD capabilities.

But inevitably, we run into an impasse. Under Linux and entirely with Open Source software, we are likely to be using “Eclipse” as our IDE, and a version of it, which does not recognize that we have Swing packages installed – in our shared, non-proprietary Java folders. I do know that paid-for versions of Eclipse exist, which again bundle Java / RAD capabilities, but we might want to obtain those, without having to pay much money. So what can be done?

The answer that suits some use of Eclipse, lies in the fact that with any Linux Eclipse install, there exists a user-space install of extensions, similarly to how the Windows flavor of Eclipse, also has such a built-in mechanism to install extensions to this IDE itself. We find that in the Help menu, there is an entry named “Install New Software”. From there, we can specify a URL to download packages from, and we can extend, or possibly confuse, our Eclipse setup. But what we install from here under Linux does not ever use ‘root’, and thus only exists in our user / home directories.

There is a relevant URL which I just learned about, from which we can tell Eclipse to install extensions to itself:

 http://dl.google.com/eclipse/inst/d2wbpro/latest/4.2 

And when we have typed in the URL, we can see a set of components available, which include 3 Swing components, plus the critically-important “Window Builder“. This Window Builder is the Eclipse extension, that actually maintains the two views. After we have installed all the relevant packages – because we often tell this wizard to install all the dependencies as well – we need to restart Eclipse. We may first have to acknowledge having to install non-signed packages.

Once this is done, under the New Projects list, we will see as the last menu entry, “Other”, referring to a miscellany of non-standard project types. And when we open that view, we will finally get to see our Swing subsection of New objects that we can create.

Doing so opens a specialized wizard, and sets up our Java / RAD project, which will eventually have a code view and a design view.

Now, the logical question does arise, of whether it did any good, to install Swing packages via the Linux package manager. Doing so places them into shared folders using root privileges, folders that are not even specific to one Java compiler used. I have run into situations before, in which Java projects designed by other programmers did not initially recognize, that these shared Java libraries even existed. This has required some workarounds in my past.

Using Eclipse, the fact is that these packages will not show up in the graphical browsers /  wizards.

But I think that this is one reason, to install all 4 components offered by the URL above, to make certain object types visible in the IDE wizard. After one has created a basic project with the code and design views, I think the next thing to try, would be just to add the ‘import‘ statements to the code view, that are meant to pull in the Swing packages we think we need, and then to see, whether the design view renders them correctly.

Whether it does so or not, next depends on the separate question, of whether All Swing packages are in fact compatible with the Google Window Builder. And even though Swing should implement a standard interface, depending on what we are trying to do, the answer might still be ‘No’.

It would be necessary to link our project to the desired JAR File explicitly, in a way that states its location in the shared, root File System… In that case, we would click on the IDE Menu, “File -> Import”. And in the window which appears, instead of choosing “Plug-Ins And Fragments”, we could choose “General -> File System”… And under Linux we would choose the folder ‘/usr/share/java‘, so that in the subsequent view, we can select the required JAR Files, knowing that they will be copied.

Then, we would right-click on the project we want to build, and click on Properties, which opens another window, from which we would choose “Java Build Path -> Libraries” …

Dirk

(Edit : ) It is entirely unproven, whether externally-supplied Swing libraries can be made to work properly, with Google Window Builder. What Google has done, is to name the Swing components of its Window Builder, as offering a ‘JPanel‘, a ‘JFrame‘, a ‘JApplet‘ etc., so that the naming of classes will not interfere with generic Swing class names. Hence, if we were to try to use Swing classes provided by the Linux package manager as stated before, first of all those would have dependencies on one or more base libraries, also located in ‘/usr/share/java‘, which would not only require that the ‘import‘ declarations be put into our Java source file, but also that the libraries be listed after the libraries that already belong to Window Builder, within the link order defined in the ‘Java Build Path‘.

The ultimate success we would want to see, would be that the Component Palette belonging to Window Builder, should offer us additional components, other than J-this or J-that. But the mere fact that the naming of classes has been separated, suggests the possibility that these external components will not be recognized by Window Builder at all.

One quick test a user could perform, would take into account the observation that Window Builder source code tends to import one specific package, such as ‘javax.swing.jframe‘. After we have appended the desired libraries to the Java Build Path, base library first, we could try to declare something that generic Swing projects frequently used:

 import javax.swing.*; 

This declaration should either work, or crash Window Builder.

(Answer : ) Doing so simply causes Window Builder to crash temporarily, until the offending declaration is removed from the code view. That is all.

In the past, the way the email service of my ISP – “Bell Canada” – worked, was that email was outsourced to Microsoft, such that at least my own ‘Sympatico’ email address, was also accessible as Web-mail, via ‘Hotmail’. The way this used to work, was that I had assigned sub-domains for accessing the POP and SMTP servers, which seemed to belong to Bell, but which nevertheless used to access my email with a Hotmail server.

Now, it had happened before that I had received emails from Bell, telling me to make sure I had updated my email server settings, to keep up with improvements that were being promised. But all those emails simply led to a site with Bell, according to which my settings were already correct as they were.

My explanation for that would be, that maybe not all Bell customers were on the same plan before, and that my arrangement with them may have been more of a testing arrangement. In any case I had visited the link each time, to make sure that the server settings recommended there, still corresponded to the server settings I had been using, and they had.

The aspect of this which is pleasantly surprising, was that as of May 3, the service was in fact upgraded – this time – and that it happened without any interruption of the service available to my POP clients, since my POP clients were already configured for the change. Thus, I had not really noticed that the upgrade had in fact taken place until later. I did, however, receive an email from Bell, saying ‘Welcome to the New Service.’

There was however a way in which I was bound to discover the improvement eventually. As long as my email was always hosted on Hotmail servers, a peculiarity of the service was, that one of my POP clients was configured to ‘Leave Email On The Server, For At Most 3 Days’, while all my other POP clients were just configured to ‘Leave Email On The Server’ (with no time limit set). This was one way I had intended to keep all my received email, on POP clients, in sync.

The problem with the earlier Hotmail arrangement was, that their servers would flagrantly disregard the command sent by my own email client, eventually to delete the emails. In fact, Hotmail had announced suspicion of my email client programs in the past, stating that ‘Some program has asked us to delete your emails. But because we do not trust this program, we have put those emails in a special folder for you.’ AFAIK, It could have been true that Hotmail did not trust this mysterious email client of mine, because mine was not a Microsoft client, being a Linux client, and there may have been some way for the Hotmail server to detect that. In fact, I am sure that email clients state a User Agent, the same way Web browsers state a User Agent.

What this meant in practice, was that every few days I would actually need to log in to my Web-mail, and to delete some emails manually, which the setting on that one email client were not sufficient to delete. Hence, it was inevitable that I would be heading back to the Hotmail, Web-mail server eventually, to look at and delete those emails.

Except that more recently, there were no emails in my Hotmail Inbox. My POP clients were still receiving emails, but my Web-mail did not reflect them. In response to this, I had actually changed the setting in the interim, so that none of my POP clients were set to have emails deleted from the server for now.

But it turns out, that the real reason for which my (old) Hotmail Web-mail was no longer showing any received emails, was this real upgrade. The new Web-mail site with Bell, shows me all the emails I have received since May 3.

What this also means, is that the potential now exists, for Bell email servers actually to follow the request of my client, to delete emails in the Inbox, older than 3 days.

Also, I happen to like the new Bell Web-mail layout better than the old Hotmail layout. And, there are No cross-scripted sites which the new Web-mail site links to, which could have been intended as advertisement under Hotmail, but which would trigger the script-blocker on my Web-browsers, that selectively blocks scripts from excessively-abusing domains. There seem to be no linked domains on the new Web-mail site, which my script blocker would want to block.

I guess that maybe, Hotmail was making some additional money on the side, which Bell does not need to make, because I am already paying Bell in full, for my services?

Dirk

## The laptop ‘Klystron’ suspends to RAM half-decently.

One subject which I have written a lot about, was that as soon as I close the lid of the laptop I name ‘Klystron’, it seems to lose its WiFi signal, and that that can get in the way of comfortable use, because to close the lid also helps shield the keyboard of dust etc..

This Linux laptop boots decently fast, and yet is still a hassle to reboot very often. And so I needed to come up with a different way of solving my problem, on a practical level. My solution for now, is to tell the laptop to Suspend To RAM, as soon as I close the lid. That way, the WiFi signal is gone more properly, and when the laptop resumes its session, the scripts that govern this behavior also re-initialize the WiFi chipset and its status on my LAN. This causes less confusion with running Samba servers etc., on my other computers.

There is a bit of terminology, which I do not think that the whole population understands, but which I think that people are simply using differently from how it was used in my past.

It used to be, that under Linux, we had ‘Suspend To RAM’ and ‘Suspend To Disk’. In the Windows world, these terms corresponded to ‘Standby’ and ‘Hibernate’ respectively. Well in the terminology today, they stand for ‘Sleep’ and ‘Hibernate’, borrowing those terms from mobile devices.

There are two types of Suspend working in any case.

In past days of Linux, we could not cause a laptop just to Hibernate. We needed to install special packages and modify the Grand Unified Bootloader, before we could even Suspend To Disk. Suspending To RAM used to be less reliable. Well one development with modern Linux which I welcome, among many, is the fact that Sleep and Hibernate should, in most cases, work out-of-the-box.

I just tried Sleep mode tonight, and it works 90%.

One oddity: When we Resume, on this laptop, the message is displayed on the screen numerous times, of a CPU Error. But after a few seconds of CPU errors, apparently the session is restored without corruption. Given that I have 300 (+) processes, I cannot be 100% sure that the Restore is perfectly without corruption. But I am reasonably sure, with one exception:

The second oddity is of greater relevance. After Waking Up, the clock of the laptop seems to be displaced 2 days and a certain number of hours into the future. This bug has been observed on some other devices, and I needed to add a script to the configuration files as a workaround, which simply sets the system clock back that many days and that many hours, after Waking. Thankfully, I believe that doing so, was as much of a workaround as was needed.

One side-effect of not having done so, before being aware of the problem, was that the ‘KNotify’ alarms for the next two days have also all sounded, so that it will take another two days, before personal organizer – PIM – notifications may sound for me again.

The fact that numerous CPU errors are displayed bothers me not. What that means, is that the way the CPU goes to sleep, and then wakes up, involves power-cycling in ways that do not guarantee the integrity of data throughout. But it would seem that good programming of the kernel does provide data integrity, with the exception of the system clock issue.

But the fact that the hardware is a bit testy when using the Linux version of Sleep, also suggests that maybe this is also the kind of laptop that powers down its VRAM. It is a good thing then, that I disabled the advanced compositing effects, that involve vertex arrays.

There is a side-note on the desktop cube animation I wanted to make.

In general, when raster-rendering a complex scene with models, each model is defined by a vertex array, an index array, one or more texture images etc., and the vertex array stores the model geometry statically, as relative to the coordinate-origin of the model. Then, a model-view-projection matrix is applied – or just a rotation matrix for the normal vectors – to position it with respect to the screen. Moving the models is then a question of the CPU updating the model-view matrix only.

Well when a desktop cube animation is the only model in the scene, as part of compositing, I think that the way in which this is managed differs slightly. I think that what happens here, is that instead of the cube having vertex coordinates of +/- 1 all the time, the model-view matrix is kept as an identity matrix.

Instead, the actual vertex data is rewritten to the vertex array, to reposition the vertices with respect to the view.

Why is this significant? Well, if it was true that Suspending the session To RAM also cut power to the VRAM, it would be useful to know, which types of data stored therein will seem corrupted after a resume, and which will not.

Technically, texture images can also get garbled. But if all it takes is one frame cycle for texture images to get refreshed, the net result is that the displayed desktop will look normal again, by the time the user unlocks it.

Similarly, if the vertex array of the only model is being rewritten by the CPU, doing so will also rewrite the header information in the vertex array, that tells the GPU how many vertices there are, as well as rewriting the normal vectors, as when they are a part of any normal vertex animation, etc.. So anything resulting from the vertex array should still not look corrupted.

But one element which generally does not get rewritten, is the index array. The index array states in its header information, whether the array is a point list, a line list, a triangle list, a line strip, a triangle strip… It then states how many primitives exist, for the GPU to draw. And then it states sets of elements, each of which is a vertex number.

The only theoretical reason fw the CPU would rewrite that, would be if the topology of the model was to change, which is as good as never in practice. And so, if the VRAM gets garbled, what was stored in the index array would get lost – and not refreshed.

And this can lead to the view, of numerous nonsensical triangles on the screen, which many of us have learned to associated with a GPU crash.

Dirk