java

Generic Java Output Library or Pattern

I'm writing a bunch of data out from a java application that gets consumed by the end user it could be to a file, console, or an arbitrary listener. It would be nice to allow the user to specify how they want to consume this data. What approach have people taken to this sort of problem, is there a good open source solution? I could see s...

How to inhibit start of WAR file within EAR file configuratively?

I have an ear file which contains 4 war files. The main reason we put those together is, that the order of startup is important, and it is easier from a deployment perspective (the customer only gets one file and does not have to worry about which versions works together). The ear files are going to be deployed on 4 different systems, w...

Running a JAR file without directly calling `java`

I am deploying a command-line tool that is written in Java that accepts command-line arguments. I have it packaged as a JAR file because it is convenient to have a single file. The problem is that to run it you must first call java -jar (filename) (args) and that is quite annoying. The current way I have it is to have a simple bash sc...

Copy all values from fields in one class to another through reflection

Hi. I have a class which is basically a copy of another class. public class A { int a; String b; } public class CopyA { int a; String b; } What I am doing is putting values from class A into CopyA before sending CopyA through a webservice call. Now I would like to create a reflection-method that basically copies all fields t...

How to marshal a DataHandler annotated as @XmlAttachmentRef with JAXB?

I'm trying to marshal an object which has a DataHandler field with JAXB (2.1.12). For streaming support, the DataHandler is annotated with @XmlAttachmentRef. Serialization and streaming over web services (Metro on JBoss) work fine, but plain marshalling with JAXB doesn't. Here is a stripped down example: public class DataHandlerAttachm...

Hibernate Mapping Two Tables to One Class

I need to map two tables to a single class, having trouble figuring this out. One table is ROOMS, the other is TRAINERS. The ROOMS table: OOC_UNIT_ID NUMBER(6,0) OOC_START_DT DATE OOC_START_TM DATE OOC_DT_MOD DATE OOC_USER_MOD VARCHAR2(30 BYTE) OOC_END_DT DATE OOC_END_TM ...

Jboss Message Bean (EJB3) - configuration name

Is there a way of specifying the configuration name of a message bean through annotations? In the jboss.xml descriptor you can have different configurations and bind the beans to a particular config: <message-driven> <ejb-name>PushUserAgentBean</ejb-name> <destination-jndi-name>queue/PushUserAgent</des...

freeware for generating diagrams

Hi, Do you know any nice freeware that will take my java sources and will generate class diagrams from them? ...

On-demand eager loading

Hi guys, I make a query: String query = "SELECT DISTINCT a FROM A a FETCH ALL PROPERTIES " + "JOIN a.Bs AS b " + "JOIN b.Cs AS c WHERE c = :c"; Query q = DAO.getSession().createQuery(query); q.setParameter("c", c); return q.list(); Even though I've said FETCH ALL PROPERTIES on a, when I access all the collections that A has...

Consume a stateful .net web service from java

In C# I have methods that use [WebMethod(EnableSession = true)] I consume them in C# .net by using a cookiecontainer to maintain state. How do I do the same thing in java? I want to call a .net webservice with [WebMethod(EnableSession = true)] and have it maintain state between calls. ...

springsource ide on macos sts.app,eclipse.app

in my springsource sts folder, i have eclipse.app and sts.app ? what is the different executing each ? should be the same right? ...

About ending conversation in SEAM 2.1.2

Hi guys, I have a question about seam 2.1.2 I want to end a conversation when the user click in menu, but this must be done in menu.xhtml or pages.xml. I need this because i have the following problem: click page 'A' in menu click in "search" button to show the list A. forget about list 'A' and click in page 'B' in menu. click in "se...

Cast down with reflection at runtime

Considering following code public class A { public static void main(String[] args) { new A().main(); } void main() { B b = new B(); Object x = getClass().cast(b); test(x); } void test(Object x) { System.err.println(x.getClass()); } class B extends A { } } ...

How to master java and ruby fastest for a PHPer?

I've been using PHP all the time. Any advice to taking on these two languages? ...

NetLogo vs. Repast Simphony?

I would like to simulate some scenarios using the multiagent paradigm, and it seems NetLogo and Repast are the most popular tools for that. I'd like to know if anyone has had any experience with either one and could tell me more about them? For example, I've noticed that there is a fluxogram-like modeling option for Repast, but I belie...

What is Type 4 XA driver?

In our application when we create the Datasource, we select the Database Name DB2 Driver: BEA Type 4 XA DB2 But what i know is, there are only 4 types of Driver. Then what is Type 4 XA driver? ...

Good JSON Java Library?

Can anyone post feedback on their experiences with various json libraries for java? In particular, does anyone have feedback on their experience with Google-gson? (I'm aware that there's a nearly identical question here, but that's over a year old, so people may have different experiences now.) ...

Java Modcount (ArrayList)

In Eclipse, I see that ArrayList objects have a modCount field. What is its purpose? (number of modifications?) ...

Eclipse Debugging - Stopping without a breakpoint

I am debugging some Java code with Eclipse 3.4.2. I have disabled all the breakpoints, yet the debugger still stops at a specific line. This point is several lines before a null pointer exception is triggered. Curiously, when I run the same code/run configuration, but not in the debugger, the null pointer exception does not occur. Also,...

Parsing problem, exception

This is my BMI calculator with GUI. It compiles, but if the user enters characters rather than numbers into the fields, the program crashes. What is wrong with my catching of the numberformatexception? Id appreciate any help! import java.awt.*; import javax.swing.*; import java.awt.event.*; class Exercise1b extends JFrame{ JLabel BMIl...