java

Type safety: Unchecked cast

In my spring application context file, I have something like: <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.String"> <entry key="some_key" value="some value" /> <entry key="some_key_2" value="some value" /> </util:map> In java class, the implementation looks like: priv...

How do I find the source code for Java SE 6 update 10?

At Java SE Downloads I may for example download: Java SE Runtime Environment (JRE) 6 Update 10 Java SE Development Kit (JDK) 6 Update 10 But I can't find any source code for update 10. If I click Java SE 6 JDK Source Code on the Java SE Downloads page it seems I can only download source for "JDK 6u3 Source". Where can I find the sour...

Is there any way to compile Java code into a DLL?

See question above. ...

Java BufferedReader back to the top of a text file?

I currently have 2 BufferedReaders initialize on the same text file. When I'm done reading the reading the text file with the first BufferedReader, I use the second one to make another pass thru the file from the top. Multiple passes thru the same file are necessary. I know about reset(), but it needs a previous call to mark() and mark...

JSF commandLink action firing before Updating Model Values

Hey all, I have a JSF application that consists of two JSPs: login.jsp & main.jsp. I have the following faces-config.xml: <lifecycle> <phase-listener>package.programs.scorecard.beans.EventBean</phase-listener> </lifecycle> <managed-bean> <managed-bean-name>FormBean</managed-bean-name> <managed-bean-class>package.programs.scoreca...

Java object to XML schema

Hi, If you have a Java object and an XML schema (XSD), what is the best way to take that object and convert it into an xml file in line with the schema. The object and the schema do not know about each other (in that the java classes weren't created from the schema). For example, in the class, there may be an integer field 'totalCountV...

When would you call java's thread.run() instead of thread.start()?

... the question says it all I believe! ...

Why HttpServletRequest.getRemoteAddr() doesn't work in Java servlet ?

I'm developing a web app with java servlet, I hope to get the user ip info by calling request.getRemoteAddr() from inside : processRequest(HttpServletRequest request,HttpServletResponse response) But it returns a wrong ip, since I'm not very knowledgeable about this area, I don't know what it is displaying, maybe a proxy, I got this : ...

Declarative XML -> POJO conversion

I have to write a process (in Java) which periodically hits a URL, reads the returned XML document, and persists that data into the DB. This data is further used by my application, so I have modeled them as Hibernate-mapped POJOs. I can parse the XML and then create appropriate POJOs, but I was looking for a simpler declarative approach...

Java URLConnection : how could I find out a file's size ?

I'm working on a project for school , and I'm implementing a tool which can be used to download files from the web ( with a throttling option ) . The thing is , I'm gonna have a GUI for it , and I will use a JProgressBar widget , which I would like to reflect how much the tool downloaded so far , and for that I would need to know the siz...

State Machine Framework for JBoss/Java?

We are developing an application that involves a lot of different tests where each test lead the users to a number of steps. We are thinking of using a state machine framework to capture the states/transitions out of the code. We are also thinking of using rule engine to supplement on the rules. Anyone has experience with any state ma...

java traits or mixins pattern?

Is there a way to emulate mixins or traits in java? basically, I need a way to do multiple inheritance so I can add common business logic to several classes ...

Are there any good J2EE value list handler pattern implementations?

Are there any good value list handler implementations available? I've found valuelist, but it seems to be stagnating... besides I really need good control of links the taglib generates, because I need to call some JavaScript from it. Currently I solve it by rewriting the taglib in freemarker and using valuelist's backend. Does anyone ...

Best Practices - Swing, Database Access

I'm a newbie to swing development. I have a swing app that needs to access data from a remote sql database. The users of the app are all located in our office. Is it bad practice to access the database directly from the swing app? Should I put database facing code into an rmi server? ...

Java.util.Calendar - milliseconds since Jan 1, 1970

Program followed by output. Someone please explain to me why 10,000,000 milliseconds from Jan 1, 1970 is November 31, 1969. Well, someone please explain what's wrong with my assumption that the first test should produce a time 10,000,000 milliseconds from Jan 1, 1970. Numbers smaller than 10,000,000 produce the same result. public st...

End of an XML stream over a JSSE connection?

I have a Java server that accepts SSL connections using JSSE and uses a simple XML message format inside the stream. I would like the server to read a complete message and then send a reply. This turns out to be quite difficult because org.xml.sax.XMLReader wants to read the entire stream and then call close(). I know it seems strange...

Generating SQL Schema from XML

We are using an Oracle 11 database and a java development environment (using Eclipse) and would like to migrate several xml schemas to SQL schemas. Have looked ax xsd but really need something that we can run from ant/ Eclipse without SQL Server installed. Regards, Andy ...

HashMap default types for K and V

I usually type my map declarations but was doing some maint and found one without typing. This got me thinking (Oh No!). What is the default typing of a Map declaration. Consider the following: Map map = new HashMap(); map.put("one", "1st"); map.put("two", new Integer(2)); map.put("three", "3rd"); for ( Map.Entry entry : map.entrySet...

Stand-alone NetBeans-compatible .form editor

Is there a stand-alone GUI designer that can read and write the .form files that NetBeans (Matisse) generates? I like the GUI designer, but I don't want all the overhead of a complete Java IDE just to create and edit .form XML files. ...

How do I convert NetBeans .form files to .java?

What's the best way to convert NetBeans (Matisse) .form files into .java files, without using the NetBeans IDE itself? Ideally I'd like to package the .form files along with my source code, and generate the .java files at build time. This will prevent developers from "accidentally" adding code to the generated .java file using some other...