I have recently developed an application and created the jar file. One of my classes creates an output directory, populating it with files from its resource. My code is something like this: Unfortunately this doesn’t work. I tried the following without luck: Using Streams to solve similar stuff on other…
Tag: java
Is there an implementation of JSR-303 (bean validation) available?
I know there are non-standard frameworks such as commons-validator, and hibernate validator. I wanted to know if someone knows an implementation of the official standard. Answer Hibernate Validator is the reference implementation of JSR-303
Using the NetBeans GUI editor, how can I create a JTextField or JFormattedText field that must be validated against a regular expression?
I have a regular expression (d{4}w{3}(0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]){2}) that I need to validate the input of a text field against when the user clicks the OK button or moves the cursor to another field. That I know how to do, writing the code. However, I’m interested in if itR…
Speeding up Tomcat in debug mode with Eclipse IDE
Running Tomcat through eclipse works fine in non-debug mode, but not in debug mode. When I try to start the Tomcat server in debug mode, the console output looks fine for a while, but then starts slowing down and eventually just stops, pegging the cpu at 100%. I don’t think it’s relevant, but just…
run php from java
Is there a way to run php server**(remote)** scripts from a java program (with secured/encrypted connection). Answer Visit (make post or get HTTP request) php page from your java program, for example, via HttpUrlConnection type
PreparedStatement setNull(..)
Java PreparedStatement provides a possibility to explicitely set a Null value. This possibility is: Are the semantics of this call the same as when using a specific setType with a null parameter? ? Answer This guide says: 6.1.5 Sending JDBC NULL as an IN parameter The setNull method allows a programmer to sen…
Find a class somewhere inside dozens of JAR files?
How would you find a particular class name inside lots of jar files? (Looking for the actual class name, not the classes that reference it.) Answer Eclipse can do it, just create a (temporary) project and put your libraries on the projects classpath. Then you can easily find the classes. Another tool, that co…
How do I manually configure a DataSource in Java?
I’m trying to follow Sun’s JDBC tutorial at http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html It gives the following example code: This code doesn’t compile because the DataSource interface has none of these methods, except for the getConnection() method invoked last. (Here…
How can I parse a date including timezone with Joda Time
This snippet of code always parses the date into the current timezone, and not into the timezone in the string being parsed. It outputs: whereas I expect: Any ideas what I’m doing wrong? Answer OK, further Googling gave me the answer to my own question: use withOffsetParsed(), as so: This works.
Reading a remote file using Java
I am looking for an easy way to get files that are situated on a remote server. For this I created a local ftp server on my Windows XP, and now I am trying to give my test applet the following address: and of course I receive the following error: URI scheme is not “file” I’ve been trying som…