java

java swing - layout oddness when using different layout managers

Bit of oddness, seen if I do the following: import javax.swing.*; public class FunkyButtonLayout { public static void main(String[] args) { JFrame frame = new JFrame(""); JPanel j0 = new JPanel(); // j0 gets added to the root pane j0.setLayout(null); JPanel j1 = new JPanel(); // j1 gets added ...

Help understanding academic notation for type system

I'm trying to understand an academic paper (pdf) about programming language design. In particular, it describes a lightweight version of Java called Featherweight Java. It has typing rules with notation like this: x_ : C_, this : C |- e0 : E0 E0 <: C0 class C extends D {...} if mtype(m,D) = D_->D0, then C_ = D_ and C0 = D0 -----...

How is a StringBuffer passing data through voids with no fields in the Class?

Given: Class has no fields, every variable is local. littleString was created by refactoring bigString in Eclipse: public String bigString() { StringBuffer bob = new StringBuffer(); this.littleString(bob); return bob.toString(); } private void littleString(final StringBuffer bob) { bob.append...

XPath search based on dynamic regular expressions

Hi I have an XML like the one below: <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Destinations> <Destination name="DEST1" > <From>AMA*</From> </Destination> <Destination name="DEST2" > <From>AMAZON</From> </Destination> ...

What would you recommend for a large-scale Java data grid technology: Terracotta, GigaSpaces, Coherence, etc?

I've been reading up on so-called "data grid" solutions for the Java platform including Terracotta, GigaSpaces and Coherence. I was wondering if anyone has real-world experience working any of these tools and could share their experience. I'm also really curious to know what scale of deployment people have worked with: are we talking 2-4...

Good protocol for FAST inter-application communication?

I am about to implement a server application that can answer queries fast. The server is implemented in java. I don't want to waste a lot of time on a complicated communication protocol so I search for a good best-practice way of 1) performing a query to my server 2) letting the server answer that query Both the queries and answers w...

Java Class Loaders

Can anyone point me a good resource or explain me about the concept behind Class Loaders? I found the following resource on class loaders http://www.onjava.com/lpt/a/5586 but still no help. The following questions may look silly but trying to answer them always confuses me. Why do developers write Custom class loaders, why not invoke a...

Book or Resource on C# Concurrency

I have heard many good things about the book Java Concurrency in Practice. Is there a good equivalent book for C#? ...

Facing problem in log4j error log and exception handling

Hi : I have used log4j for looging error log using FileAppender. The problem is its logging the same error two times in a log file when the below situation Case1: Class1 : public void func(){ try{ new Class2.prop() }catch(IOException ioe){ logger.log(2,ioe); } } Class2 : public void prop(){ try{ ...

Should enum objects be stateless?

As by design an enum constant in java is a singleton, and for sake of concurrent usage I normally create stateless enum instances and use method parameters to inject the data as needed. Example: Currently I am creating a REST service which has Operations (implemented as an enum using a variant of the strategy pattern). public enum Op...

Why main() in java is void?

In case any C syntax like languages we specify the main() method should return anything int, float, void also. But in java can we do so? If not then why only void is used for main() method. Does it mean any java program doen't return anything to OS? ...

Solving nonlinear equations numerically

Hello, I need to solve nonlinear minimization (least residual squares of N unknowns) problems in my Java program. The usual way to solve these is the Levenberg-Marquardt algorithm. I have a couple of questions Does anybody have experience on the different LM implementations available? There exist slightly different flavors of LM, and ...

How can I use the MS JDBC driver with MS SQL Server 2008 Express?

My configuration: windows XP SP3 JDBC 2005 MS SQL Server 2008 Express, exposed via tcp/ip on port 1433 sqljdbc.jar in class path I tried: try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433/SQLEXPRESS2008;databaseNa...

Running / compiling jdbc-sqlite on OSX 10.5

I can't for the life of me get the library located here: http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC and zentus.com to run in native (JNI) mode on OSX 10.5. If I query the driver for the mode it always says "pure", which means it's running in nested VM mode and pure java code is running to query the sqlite database, which is slower...

Null Inner Bean with Spring IoC

Hi all. I have a singleton bean definition like this: <bean id="exampleBean" class="com.examples.ExampleBean"> <property name="exampleBean2"> <bean class="com.examples.ExampleBean2" /> </property> </bean> where ExampleBean could be: public class ExampleBean { private ExampleBean2 exampleBean2; public ExampleBean() { } ...

Excessive memory allocation in Java Sandbox security

Under the Java security model it is possible to block most dangerous actions from untrusted classes, but the last time I checked (a few years ago now) it was still possible for untrusted code to perform a denial of service attack by continually allocating memory until the JVM crashes with an OutOfMemoryException. Looking now, I can't see...

How to set MQMD ApplicationID field via JMS API?

Hello, I'm using the JMS API to send messages to a Websphere MQ server. The application that pulls the messages i create want's me to set up the ApplicationID field in the MQMD structure to constant value. I could not find a way in the JMS API to access the MQMD structure The question: Is there a way doing this? if yes then how? If no, ...

Alternate plugin executions in maven2 ?

In the included configuration, does the "stop-jetty" execution inherit any configuration information from the outer "configuration" element? Will stopPort be 9999 in the "stop-jetty" execution even if I omit it from the stop-jetty execution ? Any documentation references on how this inheritance works would also be awesome. <plugin> ...

C# version of java's synchronized keyword?

Does c# have its own version of the java "synchronized" keyword? I.e. in java it can be specified either to a function, an object or a block of code, like so: public synchronized void doImportantStuff() { // dangerous code goes here. } or public void doImportantStuff() { // trivial stuff synchronized { // dangerous ...

How to assign a unique ID to a webservice instance

I'd like to assign an unique identifier to a soap request as soon as it arrives at my (GlassFish 2) server. I suppose I use a handler for this. But where can I store such an ID? I need it to relate log-lines from multiple classes. For this I need some sort of context-object. Anyone an idea? ...