java

How to use SQL Server Compact Edition (CE) from Java?

I want to access Microsoft SQL Server Compact Edition databases from Java. How can I do that? I searched for JDBC driver for SQLCE, but I didn't find any. ...

Confirming from a JUnit test that a FileReader was closed properly

I'm writing some Java code that uses a FileReader to load data from a few input files. I'm using TDD pretty heavily, and I'd like to add some tests that ensure that I'm cleaning up properly by calling close() on the reader when I'm done with it. Unfortunately, I can't come up with a good way to test for this. Anyone have any insights? E...

Where should you use BlockingQueue Implementations instead of Simple Queue Implementations ?

I think I shall reframe my question from Where should you use BlockingQueue Implementations instead of Simple Queue Implementations ? to What are the advantages/disadvantages of BlockingQueue over Queue implementations taking into consideration aspects like speed,concurrency or other properties which vary e.g. time to access last el...

Java: How to create a collection of a specific parent type and not its subtypes?

I am learning Java for a test (tomorrow) and am wondering about a question that will probably never come up but has got me curious. Is it possible to create a new collection class such as a list or something that can hold only a specific type and not its sub-types? Would I use generics to achieve this goal? ...

Casting between ArrayLists in Java

Hi Sorry, I thought this was an inheritance question: it was an ArrayList question all along! Ok, my problem is more specific than I thought. So I have two families of classes. Cards, and Zones. Zones are boxes for holding card. The first two subClasses of Zone, ZoneList and ZoneMap are meant to be two different ways of storing Cards...

Storing & lookup double array

Hi, I have a fairly expensive array calculation (SpectralResponse) which I like to keep to a minimum. I figured the best way is to store them and bring it back up when same array is needed again in the future. The decision is made using BasicParameters. So right now, I use a LinkedList of object for the arrays of SpectralResponse, and ...

Javolution test patterns, dos and don'ts

What are the patterns and dos and don'ts when one is writing tests for Javolution tests? In particular I was wondering: TestCase.execute() does not allow throwing of exceptions. How to deal with them? Rethrow as RuntimeException or store in a variable and assert in TestCase.validate() or something? Are there any graphical runners that ...

JUnit test with dynamic number of tests

In our project I have several JUnit tests that e.g. take every file from a directory and run a test on it. If I implement a testEveryFileInDirectory method in the TestCase this shows up as only one test that may fail or succeed. But I am interested in the results on each individual file. How can I write a TestCase / TestSuite such that e...

Is there any java library for converting document from pdf to html?

Open source implementation will be preferred. ...

How can I customise the namespace prefixes in Metro/JavaEE auto-generated WSDL?

I'm using Java 6 + JavaEE + Tomcat 6 + Metro for SOAP web services. In the response, the namespace prefixes are ns2, ns3, ns4, and so on. I'd like to be able to instruct the web services stack to use custom names instead. How do I do this? ...

Mask urls in JSP

Related to this question: URL characters replacement in JSP with UrlRewrite I want to have masked URLs in this JSP Java EE web project. For example if I had this: http://mysite.com/products.jsp?id=42&name=Programming_Book I would like to turn that URL into something more User/Google friendly like: http://mysite.com/product-Prog...

Compile CLASSPATH in a Windows batchfile

On a Unix systems it's very easy to compile the CLASSPATH by using find: LIBDIR=`find lib/ -name \*.jar` for DIR in $LIBDIR: do CLASSPATH="$CLASSPATH:$DIR" done java -classpath $CLASSPATH com.example.MyClass What would be the aquivalent in a Windows batchfile? ...

how to retrieve additional LDAP data fields via Tomcat ( getRemoteUser gives just name)

Hi, I have configured Tomcat to use LDAP / AD. How can I get more details about the logged in user, the userid is returned by request.getRemoteUser() but not the full name that I need. how do I get the actual "displayName" (full name) from AD ? I am using ldap/activedirectory/tomcat 5.5 ...

How do I use Hibernate from an Eclipse Plug-in?

I am writing an Eclipse plug-in that loads resources from a central database. I would like to use Hibernate to access that database. So how would I add this as a dependency to my plug-in project? I've tried Google but only get hits on about plug-ins for editing Hibernate configuration files. ...

How to configure JAXB so it trims whitespaces when unmarshalling tag value?

How to configure JAXB unmarshaller so it will trim leading and trailing whitespaces from strings? For instance let's consider a simple binding between a Java bean and XML using JAXB annotations: @XmlRootElement(name="bean") class Bean { @XmlElement(required=true) String name; @XmlElement(required=true) int number; } I woul...

path name and arguments of running processes using java code

I want to get the path name and arguments of running processes using java code. Is there any solution? ...

Load Balance in Distributed Project

Does anyone know a simple load balance algorithm (formula) that relates users connected, cpu load, network load and memory usage? This will be used to compare various servers and assign to a new user the best at the moment. Thank You. ...

C# equivalent to Java's continue <label>?

Should be simple and quick: I want a C# equivalent to the following Java code: orig: for(String a : foo) { for (String b : bar) { if (b.equals("buzz")) { continue orig; } } // other code comes here... } Edit: OK it seems there is no such equivalent (hey - Jon Skeet himself said there isn't, that settles it ;)). S...

How do I retrieve a URL from a web site using Java?

I want to use HTTP GET and POST commands to retrieve URLs from a website and parse the HTML. How do I do this? ...

Options to communicate between WARs in the same EAR

What options do you have to communicate between the WARs in an EAR? We have several WARs providing different webservices deployed within one EAR. For their tasks they need to communicate with the other WARs. Of course they could communicate using webservices. What other, perhaps more efficient, options are there? EDIT: The reason for t...