java

Starting Graphics & Games Programming (Java and maybe C++)

I've always had an interest in creating my own games, and now at university I have the opportunity to create some 2D and 3D games using Java and C++ for those who are that way inclined. I've never really programmed a game before, let alone graphics, so I'm completely new to the area. After a quick trip to the library today I came across...

Remote print module in Java

I am working on an application that will sport a web-based point of sale interface. The point of sale PC (I am not sure as of now whether it will run on Linux or Windows) must have a fiscal printer attached to it, but like any web app, it is the server which processes all stuff. Both server and PoS machines are on the same LAN. I must ...

Protecting internal view layer template pages in servlet applications

I have a very basic question about MVC web applications in Java. Since the olden days of raw JSP up until current technologies like Seam, a very basic pattern has always been the internal dispatch from the controller that initially accepted the request to the view layer that creates the output to be sent to the client. This internal di...

How do you store Date ranges, which are actually timestamps

Java & Oracle both have a timestamp type called Date. Developers tend to manipulate these as if they were calendar dates, which I've seen cause nasty one-off bugs. For a basic date quantity you can simply chop off the time portion upon input, i.e., reduce the precision. But if you do that with a date range, (e.g.: 9/29-9/30), the diffe...

What is the equivalent of the C++ Pair<L,R> in Java?

Is there a good reason why there is no Pair in Java? What would be the equivalent of this C++ construct? I would rather avoid reimplementing my own. It seems that 1.6 is providing something similar (AbstractMap.SimpleEntry), but this looks quite convoluted. ...

Is there a good drop-in replacement for Java's JEditorPane?

I'm not happy with the rendering of HTML by Swing's JEditorPane. In particular bullets for unordered lists are hideous. Customising the rendering seems extremely difficult. Therefore I'm looking for a replacement with better HTML rendering. Does this exist? (I asked Google, and found nothing except a promising dead link). ...

How to assert that a certain exception is thrown in jUnit4.5 tests

How can use jUnit4.5 idiomatically to test that come code throws an exception? While I can certainly do something like this: @Test public void testFooThrowsIndexOutOfBoundsException() { boolean thrown = false; try { foo.doStuff(); } catch (IndexOutOfBoundsException e) { thrown = true; } assertTrue(thrown); } I rec...

Closing a Java FileInputStream.

Alright, I have been doing the following (variable names have been changed): FileInputStream fis = null; try { fis = new FileInputStream(file); ... process ... if (fis != null) fis.close(); } catch (IOException e) { ... blah blah blah ... } Recently, I started using FindBugs, which suggests that I am not p...

Java HttpURLConnection: Can it cope with duplicate header names?

I am debugging some code in the Selenium-rc proxy server. It seems the culprit is the HttpURLConnection object, whose interface for getting at the HTTP headers does not cope with duplicate header names, such as: Set-Cookie: foo=foo; Path=/ Set-Cookie: bar=bar; Path=/ The way of getting at the headers through the HttpURLConnection(usi...

How to determine if a class is a subclass of other class ?

I'd like to check if a Class object represents a subclass of other class for example Class class1 = Class.forName("Class1"); Class class2 = Class.forName("Class2"); if(class1.isSubClassOf(class2)) // fake methos isSubClassOf { // do sth } How can I implement this isSubClassOf method ? ...

What is the best way to do java development in emacs?

What modes are the best? And any tips or tricks that make developing java in emacs a bit better. ...

In Java, how to reload dynamically resources bundles in a web application ?

We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that). When we modify a value in database, we have to reload the web server to display the new value on the web app. Is there any simple way to use the new value without restarting the web server ? (We do not want to always ...

How to setup JNDI for Sun App Server 8.2

http://localhost:8080/rtsclient/loginform.faces Url jnp://localhost:1099 Application Server Type jboss40 Datasource jdbc/ilogDataSource User rtsAdmin Password rtsAdmin The above is for jboss. Now i have deployed RTS onto Sun Application Server. And i want to configure the jndi such that. My RTS client can actually access it. How d...

Creating a REST webserver with security

Hi, I am very new to creating webservers - and I have had several goes at trying to understand them and write a quick webserver, but it's never quite 'clicked'. At the moment I am under the impression that REST would be most suitable for my purposes (I will explain later). Can anyone either show me a basic code example in Java (using T...

How to encode characters from Oracle to XML?

In my environment here I use Java to serialize the result set to XML. It happens basically like this: //foreach column of each row xmlHandler.startElement(uri, lname, "column", attributes); String chars = rs.getString(i); xmlHandler.characters(chars.toCharArray(), 0, chars.length()); xmlHandler.endElement(uri, lname, "column"); The XM...

Seam Problem: Could not set field value by reflection

Hi all, I'm having a problem with my Seam code and I can't seem to figure out what I'm doing wrong. It's doing my head in :) Here's an excerpt of the stack trace: Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field com.oobjects.sso.manager.home.PresenceHome.customerId to java.lang.String I'm trying to ge...

How to output a CDATA section from a Sax XmlHandler

This is a followup question of How to encode characters from Oracle to Xml? In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xml.sax.ContentHandler. When I try to output characters in a CDATA Section: It happens basically like this: xmlHandler.startEleme...

Dynamicaly populating a combobox with values from a Map based on what's selected in another combobox

Ok, here's one for the Java/JavaScript gurus: In my app, one of the controllers passes a TreeMap to it's JSP. This map has car manufacturer's names as keys and Lists of Car objects as values. These Car objects are simple beans containing the car's name, id, year of production etc. So, the map looks something like this (this is just an e...

Sending a keyboard event from java to any application (on-screen-keyboard)

I am working on developing an on-screen keyboard with java. This keyboard has a JComponent for every possible key. When a mouse down is detected on the button, I want to send a specific keyboard code to the application currently on focus. The keyboard itself is within a JFrame with no decorations and set to always-on-top. I found tha...

Good way to create PDF from Office documents in Java

I'm looking for a good way to convert Office (mostly Microsoft) documents to PDF in Java. I've been looking at using the OpenOffice SDK but from the samples I've looked at it looks like this requires having OpenOffice running in server mode to do the work. Does anyone know of a good way to do this? Good meaning the less external require...