Java API features: JMX, RMI and AspectJ

Lately I came across some Java features that I was not aware of.

First of all the JMX:

JMX stands for Java eXtention Management. It provides an API where using the concept of Java beans one can expose some information of the program under execution to other programs. So running a java application that uses Java Beans we can connect to that application using the Java Console (comes with the Java – I did not know about it either). With this connection one can see what resources the application is using as well check for exposed variables and methods. One can also change values or invoke methods and constructors using the jconsole! I got really excited about that.

Secondly the RMI:

The RMI API provides the Remote interface which can be used so that java applications can communicate with each other. With this API client – server application can be created which opens the filed for way more applications. Well I feel a bit stupid mentioning this feature of the RMI as I figure that someone taught Java properly will be aware of it and use it but I didn’t have such luck and here I stand impressed.

Last but not least AspectJ:

AspectJ is not an API that can be used with Java is more like a different programming language that can be used on top of it. AspectJ uses semantics that can identify existing code and either enhance it with additional code or change it and replace the code with something different. This kind of programming is called Aspect Oriented Programming and is becoming quite popular as there are many advantages to it. First of all on should not read all the code that is written to modify and change it. For example (this is what a beginner does for an exercise but I think captures much of the concept of Aspect Oriented Programming) if there is a huge application that needs logging mechanism one does need to go through the code and add the code for the logging manually. Simply add an AspectJ application that identifies method calls and class constructors and prints the desired information. So logging is added as an aspect (thus Aspect Oriented)

AspectJ identifies existing code through pointcuts which are specific parts of the code. So for example one can write an AspectJ application that identifies that everytime an access to a database is done for the first time by a user a login information is needed. So the lofin aspect aspect is implemented etc.

All the above can be combined and refined into Adaptive Computing. This means that one can develop a system that can get information from its self (JMX), remotely (RMI) and change it self (AspectJ). The possibilities are endless and the technology is already deployed in networks to handle server failures, overloads and mobile systems where a user changes access point unpredictably.


OpenGL in Java and game development

Recently I got my self into OpenGL. It is a graphics library that helps you use the 3D graphics hardware on your PC. It is open in comparison to DirectX and it is cross – platform. To see what you create you need to use some kind of a viewer. One that I tried lately is libQGLViewer which is based on Qt and can also be used across platforms although I had some trouble setting it up for windows.

libQGLViewer is nice but from my understanding supports only C++ so for me that I wanted to use Java with OpenGL I searched and found LWJGL which stands for LightWeight Java Gaming Library. This library helps use OpenGL in Java really easily. I used it with eclipse on windows without much trouble. However if you want to build a game out of it you’ll need some kind of game engine to display the graphics. Unless you want to build your own from scratch you’d better use one that is already available.

I found jMonkeyEngine really interesting. It provides a really nice engine along with a very good integrated development environment that apart from the coding part includes the graphics.

Along with programs like blender and GIMP I’m setting off to an exploration of the potential of game development. If you always wanted to make a game these are the tools just give them a try!

Introducing eclipse

And I don’t mean the vampire series. I mean the IDE (Integrated Development Environment). I used eclipse to write Java for quite some time. I finished my pre-graduate thesis with it. Lately I’ve been writing code almost exclusively on notepad++ but the idea of having an integrated environment to write any code is flickering in my mind.

The challenge. To write and compile most common code using eclipse. Apart from Java eclipse supports much more. So let’s start with installation. Eclipse is developed in Java itself so it will need a JRE to run. You can get the latest Java Runtime Environment here.

Last time I got to use eclipse I remembered that there was a package including everything. However as I was to download eclipse from the I could not find one. I downloaded the standard Java package (Eclipse Classic 3.6.2), the C/C++ package (Eclipse IDE for C/C++ Developers) and the PHP package (Eclipse for PHP Developers) that suffice for my needs. Then I extracted the eclipse folder of each one of them zips and merged the three folders into one overwriting everything. (As I guessed so it worked like a charm and I got to have java,C,C++ and web projects available).

My problem at first was that for some reason eclipse was searching for the JRE exclusively in …/eclipse/jre/ so I could not get the IDE get started at all. What I did eventually was to copy paste the JRE in my case …/java/jre6/ and rename the jre6 folder to jre.

So far I have Java, C , C++ and PHP support among with Javascript and HTML. To use LaTeX and VHDL as well I had to intall two plugins: TeXlipse and simplifide.The thing with simplifide is that it is not free. You can try it as there is a trial and it also has an academic license.

To install TeXlipse I went to Help –> Install new software and in the field “work with” I entered the url: Below TeXlipse was available to install so I checked it and then clicked on Next. Coming soon: more details on how to use eclipse.