java

Inferred wildcard generics in return type

Java can often infer generics based on the arguments (and even on the return type, in contrast to e.g. C#). Case in point: I've got a generic class Pair<T1, T2> which just stores a pair of values and can be used in the following way: Pair<String, String> pair = Pair.of("Hello", "World"); The method of looks just like this: public st...

Stopping an executable jar file

I have an executable jar file. Once started the only way to stop it is to go to the task manager and end the javaw process. Is there a cleaner way to stop it, say with an UI which a novice user can use? ...

Can I remove any implicitly imported Java library?

Can I remove any implicitly imported Java library? It may not seem useful. But I think it may reduce some execution time! ...

Using Spring's JDBC support to get output parameters

I'm using Spring's JDBC support to run SQL queries and updates on an Oracle database. I'd like to insert a row and then get the key that it was assigned (using an Oracle sequence). In normal JDBC code, I would include a RETURNING INTO clause and then register an output parameter (well described here) However, I would like to just use ...

Forcing Spring's MBeanExporter to use a particular MBeanServer

I have a web application running on JBoss 4.2.2. In order to monitor performance I have enabled the internal platform JMX server that ships with Java 5. In other words, I added: -Dcom.sun.management.jmxremote to JBoss' launch script. This works as expected. However, as a result of this, all MBeans are now registered on the platform MB...

problem in importing java class in jsp

i have created a java package in source packages in netbeans i have a jsp file in a web folder now i want to import this java package in jsp file but i am not getting my package name in import command ...

Converting Flat File to Java Objects

Does anybody know of any good libraries to convert a flat file to Java objects? I found flatworm but I am looking for alternatives. ...

Devexpress components like in Java (JSF)?

Is there any components like Devexpress (.NET) for JSF? ...

Drawing on Java heavyweight swing components

I'm working with an application in which I add a heavyweight (Canvas) to a JFrame. The Canvas is a 3rd party component, so I am required to keep it heavyweight. I'd like to add capabilities for the user to draw on the canvas and paint a selection rectangle. I don't think I can do this with the glass pane since the heavyweight canvas wil...

Specify order of elements in a SOAP response using java

I have a web service that returns a dataset object that contains the current weather forecast along with 0 or more weather alerts for a county/state. The dataset object just contains a Weather object and an array of Alerts objects. One of the clients of this would like to have it so the response gives the weather first instead of the a...

Java DOM XML is skipping xmlns properties

Hi there, I need to generate an xml file in Java, so I chose to use DOM (until there everything is ok), here is the root tag of what i need to create <?xml version="1.0" encoding="utf-8"?> <KeyContainer Version="1.0" xmlns="urn:ietf:params:xml:ns:keyprov:pskc:1.0" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xenc="http://www.w3.o...

Make a File/Folder Hidden on Windows with Java

Hi, I need to make a file and/or folder hidden on both Windows and Linux. I know that appending a '.' to the front of a file/folder will make it hidden on Linux, but how do I do this on Windows? Thanks ...

What is a good setting for noCompressionUserAgents in Tomcat?

Googling for "noCompressionUserAgents" ends up with the same boilerplate config that seems to have been copied around and yet is not very useful (and even is here on stackoverflow:) stackoverflow.com/questions/550024/tomcat-compression-does-not-add-a-content-encoding-gzip-in-the-header noCompressionUserAgents="gozilla, traviat...

Spawning and terminating a person in a sim game (in Java)

Hi all. I am developing a 2D grid based sim game. Progress is good. Been cracking out code for the last few days really well, and I've been having some issues today. I build two rooms, set the door position, and spawn a person. The person has the 2 room types that they must visit in order to be cured (It's a remake of Theme Hospital). I...

Reading large xml files one node at a time in Java with a pull parser?

I'd like to parse large XML files and read in a complete node at a time from Java. The files are to large to put in a tree. I'd like to use a pull parser if possible since it appears to be easier to program for. Given the following XML data Instead of having to check every event while using the StAX parser I'd like each c...

Embeddable Forum software for JEE Web Application.

The JEE Web Application we are currently working on requires a simple forum like feature set. Is there any Java based Forum software that we can embed into the existing Web App (java based). A minimalistic feature set should suffice. ...

Detect Robot on Server??

Hi, This question sort of extends my other question on robots and captcha. I did what everyone recommend (thanks everyone!), however is it at all possible to detect a robot on the server first? For Example (Once again, I will use Stackoverflow as a reference): Sometimes when I ask a question, Stackoverflow comes back asking me to verify...

What's the difference between boolean and Boolean in Java?

I would like to understand the difference between the Boolean and boolean types in Java, specifically as they relate to GWT. I know that methods are not supported but I want more info if it is available. ...

Internationalized word wrapping in Java

I need good word-wrapping handling for Java. Not too difficult, except for one wrinkle: since I'm working on an internationalized application, it needs to handle Chinese, Japanese and Korean text properly. In those languages, word wrapping occurs between characters, since the characters themselves are words and there are no spaces. Not o...

How to convert float to int with Java

I used the following line to convert float to int, but not as accurate as I'd like : float a=8.61f; int b; b=(int)a; The result is : 8 [ It should be 9 ] When a=-7.65f, the result is : -7 [ It should be -8 ] What's the best way to do it ? ...