java

Why do I get this compile error in Java?

In java why is the following code not allowed by the compiler? public class Test { public static void main(String[] args) { int x; int x = 4;// the error is generated here } } ...

How to fix the size of a Java heap

Hello, everyone I know Java VM has "-XMx" and "-XMs" for setting the size of the heap. It also has a feature called "ergonomics", that can intelligently adjust the size of the heap. But, I have a problem at hand requiring the heap with strictly fixed size. Here is the command line arguments: "-Xms2m -Xmx2m -XX:+PrintGCDetails" How...

Server architecture for a multiplayer game?

I'm planning to build a small multiplayer game which could be run as a java applet or a flash file in the web browser. I haven't done any server programming before, so I'm wondering what sort of server architecture i should have. It'll be easy for me to create perl/php files on the server, which the java/flash code contacts to update th...

System.currentTimeMillis() for a given date?

Since java.util.Date is mostly deprecated, what's the right way to get a timestamp for a given date, UTC time? The one that could be compared against System.currentTimeMillis(). ...

Generate PCL from PDF in Java

What is the best way to generate a PCL output file from an existing PDF file in java? ...

Ejb 3, message driven bean cooperating with a stateful session bean?

Hey! I'm relative new to both Java EE and Stackowerflow, please be kind :-) I have a bunch of devices triggering Java messages to be sent on any state change. These devices are typically active for about 30-90 minute intervals. Each event message contains a device id in addition to the event details. Central in my application is a me...

No experience since JDK 1.4. Am I still viable in the marketplace?

I understand there are factors at play here other than what JDK I used in my previous jobs, but a lot has gone on since JDK 1.4, and I haven't used any of the new 1.5 or 1.6 features in a production environment. Can that hurt me significantly? Almost every tutorial I see uses generics, enums, var args, and the like, and I wonder if I'm r...

Spring @Autowired usage

What are the pros and cons of using @Autowired in a class that will be wired up by Spring? I probably just don't understand it, but to me it almost seems like an anti-pattern - your classes start to become aware that they are tied to a DI framework, rather than just being POJOs. Maybe I'm a glutton for punishment, but I like having t...

Flicker when swapping inner Panel (Java AWT)

Hi, Just a small problem. Currently coding a Java project for a Dell Axim X51 with J9 installed. The problem is to do with my interface, for different screens I simply swap a nested Panel (note its running 1.4 and NO swing), so remove(panel) - add(newPanel). The problem is when it swaps the panels the time taken to do so is visible and ...

Anyone know of a java.util.Map implementation optimized for low memory use?

I've looked in the usual places (apache commons, google) and not been able to find one ... It should be opensource. Pretty much looking for one based on a linked list. The use case is 10'000's of maps, with not necessarily many values in. It does not need to scale up, as i can convert it when it gets too big. Some numbers, sizes usin...

problem reading serialport java

Hi,i'm reading data from serial port in java,but i'm not getting full data,it is splitting ten it will comes. example: if target device writes datas_ok but i'm getting datas_ at first read then ok second time. case SerialPortEvent.DATA_AVAILABLE: try { while (inputStream.available() > 0) { numBytes = inputStream.available()...

Java switch cases: with or without braces?

Consider the following two snippets, with braces: switch (var) { case FOO: { x = x + 1; break; } case BAR: { y = y + 1; break; } } Without braces: switch (var) { case FOO: x = x + 1; break; case BAR: y = y + 1; break; } I know that, in the snippet with braces, a new scope is created...

How to match SOAP responses to the schema

Hi I am trying to evaluate a web service. I am using the Axis API to create the requests. I send requests with some attacks, and then want to validate the obtained response to the response schema. I don't have much idea as to how can I achieve this. Can some one help me to achieve this, or give me some pointers that would give me some id...

Strange syntax for instantiating an inner class

I didn't imagine that I would encounter radically new syntax in Java anymore at this stage, but lo and behold, I just encountered something: The exact context and what the code below should do is pretty irrelevant - it's there just to give some kind of context. I'm trying to synthetically create an event in IT Mill Toolkit, so I wrote ...

Changing struts-rest idParameterName per action class

I want to have different idParameterNames for different action classes. Is that possible or do I have to write my own mapper? ...

Selenium click() event seems not to be always triggered => results in timeout?

Here's what I do: selenium.click("link=mylink"); selenium.waitForPageToLoad(60000); // do something, then navigate to a different page // (window focus is never changed in-between) selenium.click("link=mylink"); selenium.waitForPageToLoad(60000); The link "mylink" does exist, the first invocation of click() always works. But the se...

Can an EJB3 bean "self inject" and call its own methods via EJB container?

Is it possible to "self inject" an EJB in order to call local methods as bean methods? There are some cases where this could be favorable, for example if container managed transactions are used and something should be accomplished in a new transaction. An example how this could work: Foo.java: @Local public interface FoO { public ...

Interfacing Java and Quartz Composer

Hi there, I have written this event photography application that features a slideshow among other things. The application written in Java and is multi-platform. However on Mac OS X, it takes advantage of the graphics abilities of Quartz Composer by including a QC component in a Java window. The component is based on the sample that come...

Converting HTML Files to PDF

I need to automatically generate a PDF file from an exisiting (X)HTML-document. The input files (reports) use a rather simple, table-based layout, so support for really fancy javascript/css stuff is probably not needed. As I am used to working in Java, a solution that can easily be used in a java-project is preferable. It only needs to ...

Dozer : primitive int -1 value to null object mapping

Is there a way to configure dozer via its xml mapping file to convert a primitive int field value of -1 to a null object reference? The legacy object model defaults the value to -1, so that zero can be a valid selection. The newer object model we are mapping to, assumes that non-selected values will be null, and that any initialized ...