Java

Topics ranging from java runtime to server deployments and frameworks

New Eclipse Word Wrap plugin adds keyboard shortcut

Had a few spare minutes yesterday to move the eclipse word wrap plugin from sourceforge to github. While on it also added keyboard shortcut so you can switch on-off the wrapping using Ctrl+Alt+W (M1,M3+W in “Eclipse Language”). Trust me, it’s a useful plugin : ) Latest version can be installed from the update site: http://ahtik.com/eclipse-update/ [...]

Also posted in Eclipse, Tips | 5 Comments

BPMN2.0 Editor for Eclipse now available

Soon to be released jBPM5.1 is getting a new addition to its product suite – visual editor for the BPMN2 language. This was somewhat inevitable as the jBPM workflow engine moves to BPMN2.0 with the version 5 and hacking together xml files without visual guidance can be.. hmm.. less fun. For a quick background, BPMN [...]

Also posted in Eclipse, Technology | Leave a comment

Fighting with the SSL “unexpected_message” while using HTTP proxy and your own socket tunnel

Whenever you write an application that should support http proxies with your own custom SSLSocketFactory, you MIGHT run into a problem… Java JRE in itself supports proxies for HTTPS but it does NOT support SSL connections over proxy. For that you’ll need to create a separate proxy tunneling socket and layer it on top of [...]

Leave a comment

Using Glassfish Eclipse Bundle for JavaDB, JPA and JSP

Have you ever wondered how quickly one could get from installing a J2EE server to running a JSP page that fetches data from DB using modern persistency technology like JPA? To find out we (me and Ivar) did a little test-drive using recently announced Glassfish Eclipse Bundle that contains Eclipse IDE with bundled Glassfish J2EE [...]

Also posted in Eclipse, Technology, Tips | 8 Comments

Can you guess the output? junit and initialization

Can you guess the output without running the code? The relation to Eclipse is simply the fact that big part of eclipse.org is a great example of good test coverage built on top of jUnit. Plus, it was literally pulling my hair out in one of the eclipse-related testing-suites. I stepped into this a few [...]

Also posted in Eclipse, Technology, Tips | 2 Comments

Java Quiz of The Day – same private field instance for two classes

What is the smallest change to main method that makes it sysout “true”? You are allowed to change ONLY the main method! Of course changing sysout line is out of question. You can leave your answer in comments and I’ll publish/approve them together with the solution. [java] public class InstanceDemo { public static void main(String[] [...]

Also posted in Eclipse, Tips | 49 Comments

SimpleDateFormat is not thread-safe

How many of you use java.text.SimpleDateFormat as static field? I have seen this to be pretty standard practice (and have done this myself too). Be aware that SimpleDateFormat#format(..) is not thread-safe and thereby for most of the cases you should not use this as a static field in server, Eclipse RPC or any other multi-threaded [...]

Also posted in Tips | 1 Comment

Getting unsigned bytes in java

Welcome back after long overwork and vacation period Let’s start small, it’s still almost summer. Bytes in java are always signed and are quite horrible to use because of the casting and weird side-effects (or I’m just stupid enough to call it weird). But we need unsigned bytes quite a lot. Most of the time [...]

4 Comments

Avoid useless Plugin Initialization and/or Class Loading

Here’s a tip for initializing your plugins or any other singleton-like repository only when needed. Consider a code like this: if (isConfigurable()) { Bundle bundleCopy = bundle; Preferences[] preferencesCopy = new Preferences[1]; preferencesCopy[0] = new org.eclipse.core.internal. preferences.legacy.PreferenceForwarder( this, bundleCopy.getSymbolicName()); return preferencesCopy; } return null; Do you see what’s wrong there? The problem is that if [...]

Also posted in Eclipse, Tips | 3 Comments

Reason to serialVersionUID your serializable classes

Quoting Eclipse FAQ: “When classes compiled in Eclipse are written to an object stream, you may not be able to read them back in a program that was compiled elsewhere. Many people blame this on the Eclipse compiler, assuming that it is somehow not conforming properly to spec. In fact, this can be a problem [...]

4 Comments