java

What are the life cycle methods of a Java Server Page?

What are the life cycle methods of a Java Server Page? ...

JPA Delete with 2 Interlocking Entity Classes

I have 2 EJB 3 Entity Beans: @Entity public class Organisation { @Id @Column(length = 64) private String guid; private String name; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) @JoinColumn(name = "home_unit_fk", nullable = true) private Unit homeUnit; } @Entity public class Unit { @Id @Column(len...

Is J2ME's Integer.parseInt() broken?

While writing a game for J2ME we ran into an issue using java.lang.Integer.parseInt() We have several constant values defined as hex values, for example: CHARACTER_RED = 0xFFAAA005; During the game the value is serialized and is received through a network connection, coming in as a string representation of the hex value. In order to ...

How to add a timeout value when using Java's Runtime.exec()?

I have a method I am using to execute a command on the local host. I'd like to add a timeout parameter to the method so that if the command being called doesn't finish in a reasonable amount of time the method will return with an error code. Here's what it looks like so far, without the ability to timeout: public static int executeCom...

Can you make http client connections from a web app(flash, java)?

Before I jump both feet in and waste my time learning something that I can't use for my needs, I have to ask: Can I make a http connection to another website from within a java applet or a flash file? Say I have a java applet that wants to load results from google. Will the JVM give me access to such a call? What about Flash? I've read...

Java: Check whether an array is a subset of another

How can I easily check to see if one ArrayList object is contained as a subset of another? ...

How to specify an fileset exclude statement pointing to a file in Ant?

Is there a way to have an Ant Fileset->IncludesFile attribute take a property file OR any other file that contains a list of Java class files to exclude? Eg: File A.properties OR A.java contains listing abc.class mno.class xyz.class Is there a way to say to point excludesFile to file A.properties. <fileset dir="..."> <exclu...

How do I search and replace structurally in Intellij

Hello! I am migrating my Junit tests from Junit v3 to Junit v4. I was hoping to use the search and replace structurally "srs" to add an @Test annotation before all methods starting with test.* using my favorite IDE Intellij. I just cant figura out how to do it... I can create a query that will find all methods without an annotation (t...

How to set a connection timeout when using JAXRPC-RI web services client?

I'm working with a bit of a legacy component in which we interact with a SOAP web service (a technology which I absolutely, positively abhor) using some client code built using the JAXRPC-RI (reference implementation) library. I'm interested in being able to set a timeout with the stubs so that in case the web services server does not r...

Swing: How to create Events and dispatch them to a component?

I need to send some events to a component in Swing, so it is handled just like any user generated, standard Swing events. Basically, something like a macro recorder, and then executor for JEditorPane. But I need more control over the generated events. SO, assume I have an editor, I want to: capture all events sent to it, and at that...

Maven and dependent modules

Colleagues have been touting the wonders of maven and its magical dependency stuff but I'm finding that it fails at what I would consider the obvious use. Suppose I have a root folder with a master POM. Then underneath I have some projects, call them A and B B requires A and so the POM in the B folder has the appropriate dependency en...

SWT layout problem - padding for labels possible ?

I am using GridLayout in my SWT GUI app. I have the following GridData defined for each grid cell. The grid cell itself is just a label. GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.height...

Lucene Performance: Retrieve all document from Searcher

I have approximately 10 million objects indexed using NIOFSDirectory. When I retrieve documents with MatchAllDocsQuery, the performance is significantly worse than other types of Query's, such as BooleanQuery. I ran some tests, performance is approximately 100 times worse. Since I am only interested in the top n documents anyway, is...

What function do these Java annotations serve?

I'm still not clear on the purpose of annotations in Java. Initially I thought they just served as documentation. But looking at this documentation from Google App Engine Datastore, I'm not so sure. @PersistenceCapable(identityType = IdentityType.APPLICATION) looks more like a method signature. What's the purpose of this type of annota...

Why would you "store instances of the class in the database as entities"?

I'm trying to understand a line from the Google Datastore API which says: JDO uses annotations on Java classes to describe how instances of the class are stored in the datastore as entities, and how entities are recreated as instances when retrieved from the datastore. I'm sure this is a very basic question for most peopl...

XMPP Smack API RosterListener + Database Change

I'm writing an XMPP client in Java using the Smack API. I registered a roster listener for each user, and the Smack API calls... public void entriesAdded(Collection arg0) {} ... each time it notices a roster addition. Does anyone know if this listener will be set off if the database changes but not through the Smack API createEntry(...

(TIBCO BusinessWorks) How do you access a Java Global Instance method from a Java Code activity?

The TIBCO ActiveMatrix BusinessWorks Palette Reference states: "Any Java Code activity can access the shared Java Global Instance by invoking the static methods of the configured Java class", however, I've been unable to locate any code examples for doing this, or figure out the correct syntax on my own. What doesn't work: method(); C...

Problem Using JApplet that Accesses a Database on a Web Application Using Netbeans 6.5.1

I created a JApplet using Netbeans 6.5.1 that accesses a database. When the program is run by itself, it runs perfectly. The issue is when you try to put it online using a web application in Netbeans, it will not access the database. I was told by somebody that the problem is that Java security will not allow you to do this. Is this ...

Java Scaling Font with AffineTransform

Anyone have an example snippet showing how to scale a Font using AffineTransform? Thanks. ...

Creating a jar file from a Scala file

I'm new to Scala and don't know Java. I want to create a jar file out of a simple Scala file. So I have my HelloWorld.scala, generate a HelloWorld.jar. Manifest.mf: Main-Class: HelloWorld In the console I run: fsc HelloWorld.scala jar -cvfm HelloWorld.jar Manifest.mf HelloWorld\$.class HelloWorld.class java -jar HelloWorld.jar =...