Archive for category Java
Convert milliseconds to formatted String with Java
Posted by StephanBeutel in Java on 2011/10/07
Since 1.5 there is the java.util.concurrent.TimeUnit class, use it like this: String.format(“%d min, %d sec”, TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toSeconds(millis) – TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)) );
Monitoring Tomcat 7 with JMX
Posted by StephanBeutel in Java on 2011/07/15
Enabling JMX on Tomcat Enabling JMX without Authentication JMX is enabled by setting some Java properties in the command used to start an application. You will need to set the CATALINA_OPTS environment variable so the correct properties get set for to Tomcat when it starts. Furthermore, the properties you set will determine if application can [...]
Socket creation problem with Java on Linux
Posted by StephanBeutel in Java on 2011/07/04
Sometimes a problem occurs while trying to open a socket connection with Java on a Linux system. Mostly this is a problem with server settings. It happens if you’ve enables IPv4 and IPv6 on the system. To make shure Java uses only IPv4 every time a connection is created, just put a new entry in [...]
Using classes from external jars in GWT project
Posted by StephanBeutel in GWT, Java on 2011/04/27
For an introduction in GWT please see GWT tutorial. The following describes how to use external jars or Java projects within your GWT project. The standard approach in Java is to have separated projects for separate purposes. For example the domain model of the application is usually defined in its own project. One way of making these [...]
Persist detached entity
Posted by StephanBeutel in Hibernate, Java on 2011/03/03
Sometimes you have to store an object in a database. I run into the problem that I got this error: org.hibernate.PersistentObjectException: detached entity passed to persist It’s realy easy to solve this problem, just ensure to create the object to be saved after beginning the transaction. In my case I just created a constructor like [...]
Hello everyone
Posted by StephanBeutel in GWT, Hibernate, Java, Maven, Spring, Uncategorized on 2011/02/16
This blog is for all Java users. I’ll post interessting articles and tutorials about Java, Spring, Maven, Hibernate and GWT. Stay tuned. Stephan