java

Is there a java-library for rendering with a voxel-engine?

I'm interested if there are libraries in java, that render voxel-based sceneries? Open-Source is preferred, as always. ...

Generating an image with data fields using Java

How would you generate an JPG image file containing data fields that are stored and updated within a database table? The image would then be regenerated every hour or so reflecting the latest values within the database table. You would start with a basic background image, and then the generated image should contain data fields (e.g. av...

Why doesn't Java allow generic subclasses of Throwable?

According to the Java Language Sepecification, 3rd edition: It is a compile-time error if a generic class is a direct or indirect subclass of Throwable. I wish to understand why this decision has been made. What's wrong with generic exceptions? (As far as I know, generics are simply compile-time syntactic sugar, and they will be t...

How to easily load a XML-based Config File into a Java Class?

I've got a simple java class that looks something like this: public class Skin implements Serializable { public String scoreFontName = "TahomaBold"; ... public int scoreFontHeight = 20; ... public int blockSize = 16; ... public int[] nextBlockX = {205, 205, 205, 205}; ... public String backgroundFile = "...

Returning JSON in GWT

I'm still pretty new to JSON and GWT and I'm trying to figure out how to pass JSON data back from a page into my GWT app. I pass the JSON back to a class: public class GetProductTree extends JavaScriptObject { protected GetProductTree() { } public final native String getCustomerName() /*-{ return this.customername; }-*/; } ...

Why does autoboxing make some calls ambiguous in Java?

I noticed today that auto-boxing can sometimes cause ambiguity in method overload resolution. The simplest example appears to be this: public class Test { static void f(Object a, boolean b) {} static void f(Object a, Object b) {} static void m(int a, boolean b) { f(a,b); } } When compiled, it causes the following error: ...

replacing regex in java string, which contains `
` symbol

I have to replace the content of this xml string through java <My:tag>value_1 22&#xA;value_2 54&#xA;value_3 11</My:tag> so, this string has been taken from an xml and when I acquire it I have this result: <My:tag>value_1 22 value_2 54 value_3 11</My:tag> If I try to replace the content by this way: String regex = "(<My:tag>)(.*)(...

How to invalidate seam POJO session

Hi I am playing around with a little seam app that has session scope. The last method is sending as mail. How can I invalidate my session after having the mail sent? Right now, when the user calls the initial url again, the session still lives and all of the previously filled in form data is still there. I have found examples how to do...

Java - Handle multiple events with one function?

First of all, I am a complete Java NOOB. I want to handle multiple button presses with one function, and do certain things depending on which button was clicked. I am using Netbeans, and I added an event with a binding function. That function is sent an ActionEvent by default. How do I get the object that was clicked in order to trigge...

Java Problem: Returning a string entered as reverse text

Hi, I'm trying to make a method that returns a string of words in opposite order. IE/ "The rain in Spain falls mostly on the" would return: "the on mostly falls Spain in rain The" for this i am not supposed to use any built in Java classes just basic java So far i have: lastSpace = stringIn.length(); for (int i = strin...

How to change auto-generated code when creating new class in Eclipse

Whenever I create a new Java file in Eclipse and check off the option to add public static void main(String args[]), this code is generated: public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } How do i: Remove the @param args comment C...

Java: What's the difference between autoboxing and casting?

This question is about "Why does autoboxing make some calls ambiguous in Java?" But reading through the answers, there are a number of references to casting and I'm not sure I completely understand the difference. Can someone provide a simple explanation? ...

Mercurial and a sort of Continuous Integration workflow for Java project

There is a project in Java where I work. To have the project in Mercurial I know that I have to make a repository for all the classes. As there is a lot of classes I think if maybe I can have a copy of a jar made of a copy of the repository plus the modifications I have to do. So in Mercurial terms there is: A main repo with all the...

Basic array initialization and sorting question.

Hi this is a rather basic java question I have an array containing String that i want to sort using java.util.Arrays.sort when i write String[] myArray = {"A","B","C"}; java.util.Arrays.sort(myArray); it gets sorted correctly however when i have String[] myArray = new String[10]; myArray[0] = "A"; myArray[1] = "B"; myArray[2] = "...

Sandbox against malicious code in a Java application

In a simulation server environment where users are allowed to submit their own code to be run by the server, it would clearly be advantageous for any user-submitted code to be run in side a sandbox, not unlike Applets are within a browser. I wanted to be able to leverage the JVM itself, rather than adding another VM layer to isolate the...

Object reference in java

consider this simple servlet sample: protected void doGet(HttpServletRequest request, HttpServletResponse response){ Cookie cookie = request.getCookie(); // do weird stuff with cookie object } I always wonder.. if you modify the object cookie, is it by object or by reference? ...

Building resultset using collection object

Hi, I had an issue in building the resultset using java. Here it goes... I am storing a collection object which is organized as row wise taken from a resultset object and putting the collection object(which is stored as vector/array list) in cache and trying to retrieve the same collection object. Here i need to build back the resultse...

Passing "const" variable to method in Java

Is there an equivalent in Java to the passing on const references in C++? Isn't leaving out the "constness" misleading in regard to the method signature? ...

Execute a Java program from our Java program

How to execute another Java program from our Java program? I used Runtime.getRuntime().exec("_") but it throws a runtime IOException. I don't know whether I have the problem with specifying the path or something else. Can anyone please help me with the code. Thanks in advance. Regards, Arun ...

java.net.MalformedURLException: Illegal character in URL

hi, I am working on struts.I am encrypting password in one application and passing encrypted password to another application through open url connection.Some times this works fine if i click on the link again system is throwing "java.net.MalformedURLException: Illegal character in URL".Please help me. ...