Archive for the 'Java' Category

Thu
17
Feb '05
Tool of the day: Janino
by Frank Spychalski filed under Java, Work

Janino is a light-weight java compiler written in Java. Read the rest of this entry »


Fri
11
Feb '05
Eclipse Plugins
by Frank Spychalski filed under Java, Work

Eclipse Plugins Exposed, Part 1: A First Glimpse by Emmanuel Proulx is the first part of a series about eclipse plugin development. What he writes sounds pretty interesting, now I have to find the time to actually try it ;-)


Tue
1
Feb '05
Mock objects
by Frank Spychalski filed under Java, Work, articles

In Mock Objects in Unit Tests Lu Jian writes about two tools (EasyMock and Mocquer) which generate mock objects. Here’s my most frequently used mock object. Read the rest of this entry »


Fri
28
Jan '05
Ant help target
by Frank Spychalski filed under Java, Work, articles

Here’s a little addon to Eric M. Burke pretty good article “Top 15 Ant Best Practices”. Read the rest of this entry »


Fri
14
Jan '05
Is that your final answer?
by Frank Spychalski filed under Java, Work, articles

I found a nice article about the use of the final keyword in java at IBM Developerworks. Read the rest of this entry »


Thu
30
Dec '04
java memory model
by Frank Spychalski filed under Java, Work

just read a little bit about the Java Memory Model. After chapter 7 I was close to throwing the towel - but luckily, this is where the examples started ;-)


Tue
28
Dec '04
java.util.regex.*
by Frank Spychalski filed under Java, Rants, Work

A little quiz - what’s the output of this little code snippet?

Pattern p = Pattern.compile("aaa");
System.out.println(p.matcher("bbbaaabbb").matches());
System.out.println(p.matcher("bbbaaabbb").replaceAll("ccc"));

Read the rest of this entry »


Tue
21
Dec '04
“double-checked logging”-pattern
by Frank Spychalski filed under Java, Work, articles

Some time ago I ran into a not so usual logging problem: too much logging output and no way of turning off the unwanted bits. This article describes the problem of how to control the amout of logging output which is created in complex class hierarchies.
Read the rest of this entry »


Tue
21
Dec '04
PMD 2.1
by Frank Spychalski filed under Computer, Java, Work

A new version of PMD was released. After look a the release notes I noticed, that there were a couple of other releases since the version I use (1.7 or something).


Mon
20
Dec '04
Send ICMP (ping) in Java 1.5
by Frank Spychalski filed under Java, Work, articles

Problem:

I tried to ping from a Java Application (via InetAdress.isReachable(…)) but no ICMP packets were sent, a fact I verified with tcpdump. The Javadoc for isReachable says “A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained“.

Solution:

Under Linux you have to be root to be able to ping. If you look at ping and fping binaries you will notice the “s” which means the SETUID bit is set for these applications and they are executed with the userid of their owner which is root:

$ ls -l /usr/bin/fping /bin/ping
-rwsr-xr-x  1 root root 30764 Dec 22  2003 /bin/ping
-rwsr-xr-x  1 root root 22356 Oct  8 13:32 /usr/bin/fping

You have to change the owner of java to root (which was not necessary in my case) (chown root:root path/to/your/java) and set to set the SETUID bit for the java executable with (chmod +s path/to/your/java)

Warning!

I’m sorry to say, that this solution is a security risk and a major fuckup waiting to happen, because java is now always running as root! What I did is copy java to javaRoot and set the correct permissions, so I can use it if I’m 100% sure the application really must have root priviliges. But this is only a workaround and not a clean solution.

$ ls -l java*
-rwxr-xr-x  1 root root  64492 Sep 15 13:35 java
-rwsr-sr-x  1 root root  64492 Nov 22 13:56 javaRoot

addon 22.4.05
BTW, I don’t use isReachable anymore. I wrote a wrapper for fping. Why? Because isReachable sucks, if you want more then the simple information if a target is reachable or not, it’s a major PITA to figure out the response times and packet loss.