Skip to content
Advertisement

Java on OpenWrt/DD-WRT

I have an existing solution written in Java which I would love to run on OpenWrt routers. Will OpenWrt even run Java without installing a lot of dependencies? Anyone ever tried this? Answer I’ve never done it, but it is definitively possible. You won’t be able to run the full Java VM, only specialized versions of it (JamVM, PhoneME, SableVM).

Java – FontMetrics without Graphics

How to get FontMetrics without use Graphics ? I want to get FontMetrics in constructor, now I do this way: Answer Hmm… It is quite logical that you need graphics to get FontMetrics. Font height, width etc. can differ on various displays. If you have some Component, you can use it for getting FontMetrics:

How to add new elements to an array?

I have the following code: Those two appends are not compiling. How would that work correctly? Answer The size of an array can’t be modified. If you want a bigger array you have to instantiate a new one. A better solution would be to use an ArrayList which can grow as you need it. The method ArrayList.toArray( T[] a )

JUnit terminates child threads

When I test the execution of a method that creates a child thread, the JUnit test ends before the child thread and kills it. How do I force JUnit to wait for the child thread to complete its execution? Answer After reading the question and some comments, it seems that what you need is a technique for unit testing asynchronous

groovy call private method in Java super class

I have an abstract Java class MyAbstractClass with a private method. There is a concrete implementation MyConcreteClass. In my groovy test class I have I get an error that there is no such method signature for somePrivateMethod. I know groovy can call private methods but I’m guessing the problem is that the private method is in the super class, not

Increasing JRE Memory Usage in Eclipse

I read in another question that you can increase the JRE memory allowance for an app through Window -> Preferences in Eclipse, but I can’t seem to find anything related to heap memory allocation. Editing -xms/xmx values in eclipse.ini doesn’t help since those are for Eclipse itself. Answer I believe when Run > Debug Configuration (or Run Configuration), then Arguments

HttpURLConnection timeout settings

I want to return false if the URL takes more then 5 seconds to connect – how is this possible using Java? Here is the code I am using to check if the URL is valid Answer HttpURLConnection has a setConnectTimeout method. Just set the timeout to 5000 milliseconds, and then catch java.net.SocketTimeoutException Your code should look something like this:

Advertisement