Skip to content

Tag: java

How to set application name with JPA (EclipseLink)?

hello everybody i am using JPA with EclipseLink and oracle as DB and i need to set the property v$session of jdbc4 it allows to set an identification name to the application for auditing purposes but i had no lucky setting it up….i have been trying through entitiyManager following the example in this pa…

Java – Collections.sort() performance

I’m using Collections.sort() to sort a LinkedList whose elements implements Comparable interface, so they are sorted in a natural order. In the javadoc documentation its said this method uses mergesort algorithm which has n*log(n) performance. My question is if there is a more efficient algorithm to sor…

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 special…

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.t…

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 tes…