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…
Tag: java
Exporting Eclipse project with a reference to native library
I have an Eclipse project, that uses JMF, I found out I could skip the JMF installation process and still to use the CaptureDeviceManager of the JMF, and to receive the list of devices if I could point my project to the native lib of the JMF. I’ve managed to add the native lib to the IDE run/debug, but …
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…
Is it possible to add JPA annotation to superclass instance variables?
I am creating entities that are the same for two different tables. In order do table mappings etc. different for the two entities but only have the rest of the code in one place – an abstract superclass. The best thing would be to be able to annotate generic stuff such as column names (since the will be…
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…
NoSuchAlgorithmException: Algorithm HmacSHA1 not available
Look at the following line of java: If I put this in a simple test program, it runs without problems on my server. However, if I use this line in a container, I get The same JDK installation is used in both cases. After googling around a bit, I managed to get it to work by doing two things: Copying
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…
Java Serializable Object to Byte Array
Let’s say I have a serializable class AppMessage. I would like to transmit it as byte[] over sockets to another machine where it is rebuilt from the bytes received. How could I achieve this?