java

jMock Mocking Classes and Interface

I was experimenting jMock as my mocking framework for my project. I came into a situation where I need to mock both a class and an interface. I used the ClassImposteriser.INSTANCE to initiate the impostor of the context. Supposing a class Validator and an interface Person to mock. When I was going to mock the Interface Person, I ran to ...

Invalid character '&#x0' encountered

Hi, I am getting following exception while parsing the xml. Fatal error at line -1 Invalid character '&#x0' encountered. No stack trace I have Xml data in string format and I am parsing it using DOM parser. I am parsing data which is a response from Java server to a Blackberry client. I also tried parsing with SAX parser,but problem ...

Java ASN.1 compiler

Right now I'm using BinaryNotes to parse ASN.1 files for use in a Java project. It takes an ASN.1 definition and produces Java class(s) that let me manipulate ASN.1 files. I've hit a wall with extension markers (...) because it doesn't support them. The source forge project page says they're coming in the next release, but the last rele...

Create a Java Stored Procedure in MS SQL Server 2005

Can I create a java stored procedure in MS SQL Server 2005 like in Oracle or DB2? ...

Can a java file have more than one class?

What is the purpose of having more than one class in a java file.I am new to java. Edited: That can again be achieved by creating a inner class inside public class right? ...

How to map already existing java bean in JAXB

Castor framework (xml to java bean binder framework) provides functionality to map my existing java bean to xml. Can I achieve same thing using JAXB ? ...

Date processing in Java

Hi all I have 2 strings which are actually dates but they are in different format: 2004-06-01 00:00:00 (This value I get from Excel database through JDBC) 6/1/2004 Is their any pre-defined Class in Java which I can use to create Date kind of object? So that I can just invoke its constructor over these Strings and finally compare the...

Get enumeration values from Class

Is it possible to get the enumeration values from a Class? Let me elaborate this a bit. If I have an enum for example FooBar, then I can get the values of FooBar by calling FooBar.values() which will return an array with the enumerations (FooBar[]). My problem is, that I have a method which takes as an input parameter a class (Class c) a...

What's the Ruby equivalent for Java's StringReader?

In Java, one can create an IO stream from a String like so: Reader r = new StringReader("my text"); I'd like to be able to do the same in Ruby so I can take a string and treat it as an IO stream. ...

Create multiple Java Threads at once

Is there any possibility to create the threads as follows, Thread odjhygThread= new Thread(objJob1, objJob2); I think we couldn't, if we want to create what needs to be done? anyone knows the answer? Thanks in advance. ...

Eclipse JFace's Wizards (Again ...)

Now that I am able to set the content of my second wizard's page depending on the first page selection, I am looking for a way to give the focus to my 2nd page's content when the user clicks the next button on the first page. By default, when the user click the next button, the focus is given to the button composite (next, back or finis...

Why should I sign my JAR files?

Why should I sign my JAR files? I know that I need to sign my client-side JAR files (containing Applets) so that special things like filesystem access can be done, and so that the annoying bit at the bottom of windows doesn't show, but why else? And do I need to sign my server-side JAR files containing Servlets, etc.? Some basic rules ...

Eclipse plugin for working with protobuf

Protocol Buffers (protobuf) are a way of encoding structured data in an efficient yet extensible format. There's plugin for Netbeans, but I cannot find one for Eclipse. Does it exist? If yes, please, share the link. Thanks. ...

Java Swing design pattern for complex class interaction

I'm developing a java swing application that will have several subsystems. For all intents and purposes, let's assume that I am making an internet chat program with a random additional piece of functionality. That functionality will be... a scheduler where you can set a time and get a reminder at that time, as well as notify everyone on ...

Strange problem with imports in Java Application

I'm building a plugin to extend the Eclipse BPEL Designer. That plugin is supposed to allow users to add meta information to certain model elements via EAnnotations. I already did the same thing for a BPMN model and it work just finde but when doing this for the BPEL designer I reveive rather strange exceptions. The first I thing realiz...

Problem with JERSEY and JAX-RS

I am new to RESTful Services. I am trying to deploy a simplest REST service using jersey, and JAX-RS, but i am getting this error, HTTP ERROR: 404 NOT_FOUND RequestURI=/hosting/demo/example Powered by Jetty:// Where i think i have done everything right, below is the code i am using for it. POM.XML (only pasting the part related to je...

Experience with Drools Flow and/or OSWorkflow?

I'm looking for a straightforward Java workflow engine that: can handle both automated and manual (GUI-based) steps within a workflow supports long-running, asynchronous tasks provides support for restarting workflows in the event of a server crash stores a full audit history of previously executed workflows provides easy access to thi...

How do you check the browser's user agent in a JSP page using JSTL, EL?

I need to check the browser's user-agent to see if it is IE6. However I shouldn't use scriptlets (we have a strict no scriptlets policy) to do this. Currently I use <% String ua = request.getHeader( "User-Agent" ); boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 ); %> <% if( isMSIE ){ %> <div> <% } %>...

When not to use Regex in C# (or Java, C++, etc.)

It is clear that there are lots of problems that look like a simple regex expression will solve, but which prove to be very hard to solve with regex. So how does someone that is not an expert in regex, know if he/she should be learning regex to solve a given problem? (See "Regex to parse C# source code to find all strings" for way I am...

Hibernate load UserType object from repository

Setting: I have an object (AProduct) persisted by hibernate in my database. This object references another object (AComponent) stored in a repository. In the database table of the product only the ID of the component should be stored. By loading the product, I want to load the correct component from my repository. My solution so far is ...