java

Best Eclipse version for Java development

There are many editions of Eclipse for Java development. I am trying out MyEclipse and am pretty impressed with the out-of-box experience. Before I get too comfortable with it, I would like to find out if it is the best edition available. Feel free to list free or commercial packages, but for the sake of other readers, please mention ...

How can I build an Eclipse plugin outside of Eclipse?

I have a series of Eclipse projects containing a number of plugins and features that are checked into CVS. I now need to run an automated build of these plugins. Ideally I'd like to do it without having to hardcode large numbers of Eclipse library locations by hand, which has been the problem with the automatically generated Ant files th...

Hibernate Annotation Placement Question

Hi -- I've got what I think is a simple question. I've seen examples both ways. The question is - "why can't I place my annotations on the field?". Let me give you an example.... @Entity @Table(name="widget") public class Widget { private Integer id; @Id @GeneratedValue(strategy=GenerationType.AUTO) public Integer getId() { retu...

What would be the simplest way to deal with a text file using JSP?

First and foremost I should acknowledge that I have no experience at all using Java ServerPages, but I'm positive about achieving this task if you guys help me out a bit since it doesn't seem like something difficult for a seasoned JSP programmer. Anyway the thing is, there's an actual running JSP application within a *NIX box which I s...

How do I include jars in a groovy script?

I have a groovy script that needs a library in a jar. How do I add that to the classpath? I want the script to be executable so I'm using #!/usr/bin/env groovy at the top of my script. ...

JPA CascadeType.ALL does not delete orphans.

I am having trouble deleting orphan nodes using JPA with the following mapping @OneToMany (cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "owner") private List<Bikes> bikes; I am having the issue of the orphaned roles hanging around the database. I can use the @org.hibernate.annotations.Cascade Hibernate specific tag ...

How to boost productivity in my Flex/Java stack?

I am embarking on a new RIA project with Java on the backend. I'm the only developer, and the app is a line-of-business application. My current stack looks like this: MySQL || Spring(JdbcTemplate for data access) || BlazeDS (remoting) || Flex(Cairngorm) My question is: what changes can I make to improve productivity? Manually coding SQ...

What Happened To Java (Specifically The Language)?

Back in 2000 (when .NET was unleashed upon us IIRC) it was an innovative cutting edge language (last time I used it was 2003). From what I read though, Sun has only evolved the language exceedingly slowly. I've even read that where the language has evolved, such as the addition of Generics, developers have complained about poor implemen...

JRuby and Java objects

Please tell me if it's possible to do the following thing : create an instance of a specific class in Java pass it to JRuby to do something with it continue using the "modified" version in Java Please provide a small working example if it's not too much to ask . EDIT : turns out embedding was the simplest way to achieve this . More ...

Copying listeners/observers in a copy constructor

I'm programming a class that implements the observable pattern (not the interface) and I'm thinking about whether or not the copy constructor should also copy the listeners. On the one hand the copy constructor should create an instance that is as close as possible to the original instance so that it can be swapped out in the display co...

Java: Collections.emptyList() returns a List<Object>?

I'm having some trouble navigating Java's rule for inferring generic type parameters. Consider the following class, which has an optional list parameter: import java.util.Collections; import java.util.List; public class Person { private String name; private List<String> nicknames; public Person(String name) { this(name,Coll...

How to check if a variable exists in a FreeMarker template?

Hi, I have a Freemarker template which contains a bunch of placeholders for which values are supplied when the template is processed. I want to conditionally include part of the template if the userName variable is supplied, something like: [#if_exists userName] Hi ${userName}, How are you? [/#if_exists] However, the FreeMarker man...

Hibernate: Automatically creating/updating the db tables based on entity classes

I have the following entity class (in Groovy): import javax.persistence.Entity import javax.persistence.Id import javax.persistence.GeneratedValue import javax.persistence.GenerationType @Entity public class ServerNode { @Id @GeneratedValue(strategy = GenerationType.AUTO) Long id String firstName String lastName } and m...

Does using final for variables in Java improve garbage collection?

Today my colleagues and me have a discussion about the usage of the final keyword in Java to improve the garbage collection. For example, if you write a method like: public Double doCalc(final Double value) { final Double maxWeight = 1000.0; final Double totalWeight = maxWeight * value; return totalWeight; } Declaring the ...

JAVA: Build XML document using XPath expressions

I know this isn't really what XPath is for but if I have a HashMap of XPath expressions to values how would I go about building an XML document. I've found dom-4j's DocumentHelper.makeElement(branch, xpath) except it is incapable of creating attributes or indexing. Surely a library exists that can do this? Map xMap = new HashMap(); xM...

Search for a regexp in a java arraylist

ArrayList <String> list = new ArrayList(); list.add("behold"); list.add("bend"); list.add("bet"); list.add("bear"); list.add("beat"); list.add("become"); list.add("begin"); There is a way to search for the regexp bea.* and get the indexes like in ArrayList.indexOf ? EDIT: returning the items is fine but I need something with more per...

Native Swing Menu Bar Support For MacOS X In Java

A link that stands out is http://www.devdaily.com/blog/post/jfc-swing/handling-main-mac-menu-in-swing-application/ however the menu bar under Mac OS X displays as the package name as opposed to the application name. I'm using the code in the above link without any luck, so I'm unsure if anything's changed in recent Mac OS versions. Her...

What ever happened to Java and Sun?

What happened to Java and Sun? The community surrounding them had some of my favorite tools and software to develop with. The Java platform anyway, still looked like it had some promise to it: Groovy and Grails. Why does all of this seem to be going the way of the dodo lately? (Yes, I know their stock price is dropping badly.) Is it j...

Resetting a field lazy-loaded with the double-check idiom

Consider the "double-check idiom for lazy initialization of instance fields": // Item 71 in Effective Java copied from this interview with Bloch. private volatile FieldType field; FieldType getField() { FieldType result = field; if (result == null) { // First check (no locking) synchronized(this) { result = f...

DOM like API for working with XQuery in Java

Hi, is there some open source Java API (ideally not GPL) for creating an object model from an XQuery string? thanks ...