Monthly Archives: May 2012

jmxterm is a nice command line JMX client

Suppose you have exposed some mbeans using JMX. You can connect to the JMX service like this:

java -jar jmxterm.jar --url $service_url

where service_url is the URL of the JMX service, which you can usually find out in the logs when starting up your service. In my case, working in a Camel container, it looks like this:

service:jmx:rmi:///jndi/rmi://localhost:1188/jmxrmi/camel

Next you need to find the bean you want to manipulate, you can search for available beans with the beans command. To narrow down the list, it is helpful to specify the domain of the bean, for example:

beans -d net.sf.ehcache

Next, to do something with the bean you need to select it with the bean command, for example:

bean -d net.sf.ehcache $bean
run someMethodOfTheBean

where bean is the full name of the bean as you found previously with the beans command. It’s pretty long, so you definitely want to copy & paste rather than typing.

You can put this commands in text file and run them non-interactively like this:

java -jar jmxterm.jar --url $service_url -i /path/to/my-jmx.script

You can get jmxterm from here, with good documentation:

http://wiki.cyclopsgroup.org/jmxterm

If you need a GUI tool, VisualVM (the official tool by Sun) is fantastic.

http://visualvm.java.net/

I actually blogged about that a while back:

http://www.janosgyerik.com/how-to-browse-jmx-mbeans/

How to increase JVM heap size for Maven

Do not edit mvn (or mvn.bat) itself. Add any necessary JVM arguments to the MAVEN_OPTS environment variable.

-Xmx512m

Depending on your environment, increasing the max heap may not be enough, you might get a different kind of OOM:

java.lang.OutOfMemoryError: PermGen space

The “PermGen space” is for storing information about the heap itself. The bigger the heap, the PermGen space also needs to be bigger, you can increase both like this:

-Xmx512m -XX:MaxPermSize=128m

How can I decide which permissions to allow or disallow to an Android application?

As far as I know, I cannot. When you install an Android application you get a list of “permissions” the app wants to use, but you have only two choices, all or nothing: allow all permissions and install the app, or don’t install at all.

A few days ago I needed a random number generator, basically to simulate a dice. Sounds simple enough, I thought there must be an app for that. So I tried a couple, but they all require some permissions I really don’t want to give, for example:

  • Random Number Generator #1
    • Network communication – full internet access
  • Quick Random Number Generator
    • Network communication – full internet access
    • System tools – prevent phone from sleeping
  • Random Number Generator #2
    • Network communication – full internet access
    • Your location – coarse (network-based) location
  • Random Number Generator #3
    • Network communication – full internet access
  • Dice
    • Network communication – full internet access
  • Dice Me Online Free
    • Network communication – full internet access
    • Phone calls – Read phone state and identity
  • Simple Dice (Free)
    • Network communication – full internet access
    • Storage – modify/delete SD card contents
    • Your location – coarse (network-based) location, fine (GPS) location
    • Phone calls – read phone state and identity

At this point I give up. It’s too hard to find an app that just generates random numbers without requiring any permissions. I get it, many of the above apps are free, and probably it’s because of the in-app advertisements that they require internet access.

Wouldn’t it be great if instead of just getting a list of permissions an app wants, I could select with checkboxes the permissions I’m willing to allow? Apps could query if they have some permission and handle it gracefully if not. That would be great. Wonder why they didn’t make it work like that in the first place. Advanced search where I can specify permissions I’m willing to allow would be nice too.

Installing Subversion plugin in Eclipse

Sometimes Eclipse really sucks. Today I wanted to upgrade my subversion plugin and ended up wasting a lot of time on it.

How to upgrade a plugin in Eclipse?

  • Help / Check for Updates
    • This will scan all your plugins, taking a long time, when I want to upgrade one specific plugin
    • In this case it’s also pointless (as I found out later), as the Subversion plugins are on separate upgrade sites per version (different site for 1.6, 1.8, etc)
  • Help / Install New Software
    • It seems this is the way to go, but why so non-intuitive name?

Well this didn’t work. I got all kinds of errors that didn’t make much sense:

  • “Cannot install XYZ plugin because it already exists. Upgrading instead.”
    • Except it could not upgrade, due to some conflicts in dependencies which again, didn’t make much sense.
  • Next I tried uninstalling all Subclipse related plugins to resolve the conflicts.
    • The uninstall seems to work successfully, but when I try again the install, it still complains that XYZ plugin is still installed.
  • Next I tried removing all the files in ECLIPSE_HOME/plugins that seem related.
    • Then I get stuck when downloading the new jars, “read timed out”
      • … despite the fact that I can download those files in a browser
      • … despite the fact that some of the mentioned files are already downloaded in the plugins directory
      • … same result even if I manually download the jars and put them in plugins directory

The final solution was to download the ZIP file from the Subclipse site and install locally, from here:

http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA

Eclipse is (usually) pretty great. If only they could iron out these kind of issues already. They existed for as long as I can remember…