java

Retrieving session ID value from a JSF request

How do I retrieve the session ID value inside a JSF managed bean? ...

[Java] how to model a friends system with persistency layer?

Hi am i'm trying the new Java support for google app engine, and i am trying to make a persistency layer for all my objects. I am trying to model a friend connection but am running into problems. I use JPA to persist the objects and define my persistency objects with JPA annotations. My idea was to do the following: User Object: @E...

Having 2 variables with the same name in a class that extends another class in Java

Hello everyone. Following is a part of my code for a project: public class Body extends Point{ public double x, y, mass; public Body() { x = y = mass = 0; } public Body(double x, double y, double mass) { this.mass = mass; this.x = x; this.y = y; } } public class Point { public double x; ...

Call repaint from another class in java?

Hi all. I'm probably doing this wrong, so please be nice. I'm developing a java game, and I'm at the stage of testing character movement / animation. The "person" can move up down left and right on a grid. The class the grid is drawn in the gamePanel class. The buttons are in the gameControlPanel class. I have a button which spawns a p...

Storing UUID as base64 String

I have been experimenting with using UUIDs as database keys. I want to take up the least amount of bytes as possible, while still keeping the UUID representation human readable. I think that I have gotten it down to 22 bytes using base64 and removing some trailing "==" that seem to be unnecessary to store for my purposes. Are there an...

Ugly looking java data structure

I've created the following structure which maps unique double values to one or more pairs of integers: @SuppressWarnings("boxing") private static final HashMap<Double, Integer[][]> rules = new HashMap<Double, Integer[][]>() { private static final long serialVersionUID = 1L; { put(-0.6, new Integ...

Java - local class and generics, why compiler warning?

Named local classes are very rarely used, usually local classes are anonymous. Does anybody know why the code below generates a compiler warning? public class Stuff<E> { Iterator<E> foo() { class InIterator implements Iterator<E> { @Override public boolean hasNext() { return false; } @Override public E next() { return ...

Inserting a Java string in another string without concatenation?

Is there a more elegant way of doing this in Java? String value1 = "Testing"; String test = "text goes here " + value1 + " more text"; Is it possible to put the variable directly in the string and have its value evaluated? ...

Qt best choice for animation on embedded?

I'm looking into technologies for a new embedded product that has a 1 ghz via processor, and a via s3 graphics chip. So far the target platform is Linux, but would like the option to move it over to a windows based platform. The application would consist of widgets like buttons, graphs, and numeric/text displays. More importantly, the ...

Getting XML Node text value with Java DOM

I can't fetch text value with Node.getNodeValue(), Node.getFirstChild().getNodeValue() or with Node.getTextContent(). My XML is like <add job="351"> <tag>foobar</tag> <tag>foobar2</tag> </add> And i'm trying to get tag value (non-text element fetching works fine). My Java code sounds like Document doc = db.parse(new File(a...

Accents in file name using Java on Solaris

I have a problem where I can't write files with accents in the file name on Solaris. Given following code public static void main(String[] args) { System.out.println("Charset = "+ Charset.defaultCharset().toString()); System.out.println("testéörtkuoë"); FileWriter fw = null; try { fw = new FileWriter("testéörtk...

How can I implement a threaded UDP based server in Java ?

How can I implement a threaded UDP based server in Java ? Basically what I want, is to connect multiple clients to the server, and let each client have his own thread. The only problem is, that I don't know how to check if a client is trying to connect to the server and spawn a new thread for it. boolean listening = true; System.out.p...

Is there a good alternative to javax.imageio out there?

I'm looking for a good alternative to the javax.imageio package, that lets me do simple rotating, cutting and scaling operations on images. For example, I would like to do int angle, height, width; image.rotateRight(angle).scale(height, width); in order to obtain an image that is rotated angle degrees to the right and scaled down to h...

Java mail problem with Turkish characters

I have problem of showing Turkish characters in mail sent with Java code. The characters are shown as question marks (?) in mail. Message msg = new MimeMessage(mailSession); msg.setHeader("Content-Encoding","ISO-8859-9"); msg.setFrom(new InternetAddress(from)); InternetAddress[] address = {new InternetAddress(to)}; msg.setRecipients(Mes...

Bean merging in java

Hi, I have got a Jibx bean which is used as both input and output to a webservice. The bean is very large and complex with deep parent child relationship. The webservice does not return the request object but returns a new bean with some properties populated. I would like to merge my request and the response. I tried using Dozer (it just...

Webservice to get stock quotes?

I want to create a website similar to Yahoo finance, but much less complex for an independent study. I will be using Java to do this and would like to get stock quotes through a web service as part of the learning experience. It needs to be free or low cost and ideally would be real-time although do to licensing that probably won’t hap...

How to learn AJAX using jQuery in a Java web app

Can someone point me to tutorials using jQuery to create AJAX apps with Java (servlets). I was looking at the tutorial Implementing Ajax in Java web application using JQuery, which is similar to what I need, but it doesn't include most of the detail. If you know of a good tutorial, text + graphics or video or know the main steps and can...

How can I build a GWT Loading Dialog?

I have a page with a mix of HTML and GWT components. I'd like to not make the content viewable to the user until the content has completely loading (perhaps showing a simple loading dialog during the process). What is the easiest way of achieving this? ...

How to refactor, fix and optimize this character replacement function in java

While tuning the application, I found this routine that strips XML string of CDATA tags and replaces certain characters with character references so these could be displayed in a HTML page. The routine is less than perfect; it will leave trailing space and will break with StringOutOfBounds exception if there is something wrong with the...

Can JAX-WS be used to let a server execute web service calls on a client?

Hello! I'm playing around with P2P. I want to use JAX-WS for communication inside a P2P network. Some peers are "behind a firewall", so they can't listen on ports. (They act as clients). Other peers are allowed to listen on ports. (They act as servers (and clients)). Now I want to be able to abstract from the fact, which peers are serv...