java

EHCache Disable/Shutdown

Is there a way to disable ehache externally using a property file? CacheManager.shutdown() doesnt seem to work? Actually we have 2 app with the same source code i require ehcache in one and not the other. one where i dont need cache is a webapp! Unable to figure to out yet how to go about this? ...

Content type set incorrectly in javax.mail.Part

I have a javax.mail.Part and need to modify the content, so I have code like this: System.out.println(part.getContentType()); String content = (String) part.getContent(); content = content.replace("a", "b"); part.setContent(content, part.getContentType()); System.out.println(part.getContentType()); This prints out text/html then text/...

Hamcrest's hasItems

Why does this not compile, oh, what to do? import static org.junit.Assert.assertThat; import static org.junit.matchers.JUnitMatchers.hasItems; ArrayList<Integer> actual = new ArrayList<Integer>(); ArrayList<Integer> expected = new ArrayList<Integer>(); actual.add(1); expected.add(2); assertThat(actual, hasItems(expected)); error copi...

Mixing Hamcrest and TestNG

Has anyone integrated Hamcrest with TestNG so that its matchers can easily be used in TestNG assertions? ...

Java/Groovy Rails Database Migrations

Is there a tool in the Java/Groovy world that lets me manage database changes similar to the way that Rails Database Migrations work? ...

Parsing wikimedia markup - are EBNF-based parsers poorly suited?

I am attempting to parse (in Java) Wikimedia markup as found on Wikipedia. There are a number of existing packages out there for this task, but I have not found any to fit my needs particularly well. The best package I have worked with is the Mathclipse Bliki parser, which does a decent job on most pages. This parser is incomplete, how...

Java : What is - public static<T> foo() {...} ?

I saw a java function that looked something like this- public static<T> foo() {...} I know what generics are but can someone explain the in this context? Who decides what T is equal to? Whats going on here? EDIT: Can someone please show me an example of a function like this. ...

Hibernate CollectionOfElements EAGER fetch duplicates elements

I have a class called SynonymMapping which has a collection of values mapped as a CollectionOfElements @Entity(name = "synonymmapping") public class SynonymMapping { @Id private String keyId; //@CollectionOfElements(fetch = FetchType.EAGER) @CollectionOfElements @JoinTable(name="synonymmappingvalues", joinColumns={@Joi...

does openid4j work for google openid?

have anyone tried this, create openid4j servlet and try authenticate with google openid? i tried it and fail and so want to get confirmation from you all. i able to authenticate with yahoo_email and myopenid.com ...

Why do I get "No transports initialized" error when starting JBoss with remote debugging?

I've modified my run.sh file and added JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n" but when I start JBoss I get FATAL ERROR in native method: No transports initialized. Looking around the internet it seems like it may having something to do with missing jars or my version of Java? I'm o...

Can you help me avoid a kludging JUnit in a master/slave Ant build setup?

We're using the task within our master build to invoke targets in separate ant builds for each of our sub-projects. So far so good, we get things built, we can even run JUnit tasks within each one and everybody is happy. However... We want to take it to the next level, we would like to have a single JUnit report generated from the JUni...

Blackberry - Field - Horizontal alignment

Hello, I want to align a Custom Button Field (the Star on the Screenshot) to the center in a Horizontal Manager Definition of the HFM final HorizontalFieldManager _navigation = new HorizontalFieldManager(HorizontalFieldManager.NO_VERTICAL_SCROLL | HorizontalFieldManager.FIELD_VCENTER | Field.USE_ALL_WIDTH) { protected void paint...

Hibernate Basic: how to query when there is a composite id

Hi, I have a domain object say, SalesOrder which has a composite id called id, made of salesOrder id and repid which is contained in another class called SalesOrderID(which is serializable and implements equals and hashcode) my question is when i want to query SalesOrder, session.createSQLQuery("FROM SalesOrder where id=:soID") and so...

Good tutorial for Java events?

I'm looking for a good tutorial into Java events. Something in the core framework that allows simple event semantics (similar to C#'s events). Googling for Java events gives a page from Swing UI documentation and some other page from 2002, which hardly seems appropriate. ...

Hibernate: Sorting by a field from a linked table if foreign key is null

Lets say I have two tables - "Cat" and "Cat owner" that are linked with many-to-one like this: <class name="com.example.Cat" table="cat"> ... <many-to-one name="owner" class="com.example.CatOwner" column="owner_id" not-null="false" insert="true" update="true" cascade="none" lazy="false"/> </class> Now I w...

What's wrong with using super() in a constructor in Java?

When I run static analysis on the following code: public ExtractDBScripts(String resBundleName) { super(); m_mainBundle = ResourceBundle.getBundle(resBundleName); } I get the following error: "JAVA 0058 Constructor 'ExtractDBScripts' calls super()". What is wrong with calling super() from a constructor?...

How to instantiate an ArrayList<?> and add an item through reflection with Java?

I am writing a deserialization method that converts xml to a Java object. I would like to do this dynamically and avoid writing hard coded references to specific types. For example this is a simplified version of one of my classes. public class MyObject { public ArrayList<SubObject> SubObjects = new ArrayList<SubObject>(); } Her...

Reference Java DLL in C# Assembly?

There are instructions here to create a C# assembly using the SimMetrics library. The link they provided to this library is at SourceForge. It looks like the most recent version of the SimMetrics library was created in Java. Is it possibly to compile a java DLL and then reference it in C# to be used as an assembly in SQL Server 2008? ...

Optimal way to sort a txt file in Java

I've got a CSV file that I'm processing using the opencsv library. So I can read in each line. The particular transformation I need to do requires me to sort that file first before I run through it with the main portion of my java file. e.g. 5423, blah2, blah 5323, blah3, blah 5423, blah4, blah 5444, blah5, blah 5423, blah6, blah s...

How to make the background of a JCheckBox transparent?

Is there an easy way to make the background of a JCheckBox transparent? The box itself and the text should both be ordinary colored. Thanks in advance ...