The Java Coffee Cup Logo

Remote Debugging of Java Applications

At work I tried to debug the Java application that we provide to our customers. A nasty performance problem had developed in the course of time. To analyze this, I can recommend using VisualVM. It’s part of Oracle’s JDK (version 6 and up) but is also available as a stand alone download.

VisualVM also allows for remote debugging an application. To this end you can use the “jstatd” application, also part of Oracle’s JDK. When I used this app for some testing, I encountered the following exception at start up:

Could not create remote object
access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)
java.security.AccessControlException: access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:536)
at java.lang.System.setProperty(System.java:699)
at sun.tools.jstatd.Jstatd.main(Jstatd.java:122)

Vinay Singla has the answer on his blog. He explains that to run the application requires some permissions before it can run:

Cause :- The “access denied” error is expected, because “jstatd” requires a security policy file specified with the “java.security.policy” system property, if there is no security manager running on the machine.

His solution (as ‘translated to a Windows environment’, by me):

  1. Inside a DOS-box/Console, change to the bin directory, inside the JDK directory. (e.g. c:\program files\java\jdk7\bin)
  2. Check if a file exists with the name “jstatd.all.policy”. If not, create it with Notepad. If so, edit it with Notepad.
  3. Add this information to the file:
    grant codebase “file:${java.home}/../lib/tools.jar” {
    permission java.security.AllPermission;
    };
  4. Run this command: jstatd -J-Djava.security.policy=jstatd.all.policy
  5. Now you can connect to this machine via VisualVM.

Via http://dbafusion.blogspot.nl/2010/05/jstad-error-could-not-create-remote.html

Enter: Kitchen Timer

Years ago I taught myself to program PHP by focusing on both reading the PHP manual and simply starting to write. The goal was creating my own forum software (like everybody else was doing at the time) and by doing so, learning everything I needed about PHP (and MySQL for that matter).

Fast forward to now and I find myself in the same situation: I want to learn how to program for Android and I need a goal, or rather a means, to achieve that. I decided that (also like to many others are doing now) I want to write a kitchen timer.

Read more

A start

If there isn’t already, there ought to be a saying: any great program starts with its first steps. Or keystrokes. Or bytes.

 

As I mentioned in my previous post, I am attempting to teach myself to develop for Android. Today I endeavoured on this journey, first stop: http://developer.android.com/

This is the official Google website for everything related to developing your Android applications. They have an installation guide, a development guide, tutorials, etc. If you ever wish to start developing, I suggest you first follow the installation guide and after that, simply read the entire development guide. In my opinion, if  you’re an experienced Android user and programmer, you should have no problem reading it from A to Z, without interruption.

So, to summarize;

  • installed Eclipse
  • installed the Java SDK
  • installed the Android SDK
  • installed the Android plugin for Eclipse
  • started reading the guides
  • installed blogging software on website to keep track of developments

I have only fired up Eclipse and the SDK to check if no errors are produced, but a bit later I’ll try the samples to broaden my understanding. For now I’ll simply continue reading the guides.

PS: And yeah, I already have an idea for an application I want to develop. It would be a bad idea to simply start this project while not knowing what the goal would be.