java

[Java] What is wrong with this array declaration?

All right so I have agonized over this code for the past hour or so. This is the code for the class in question. public DistanceProject(String costs, String firstString,String secondString) { Scanner scan = new Scanner(costs); copyCost = scan.nextInt(); replaceCost = scan.nextInt(); deleteCost = s...

what are the differences of Inheritance & java Beans?

what are the differences of Inheritance & java Beans? ...

EHCache doesn't seem to work

Hello guys, I've set up ehcache on our Java application, which uses Spring and Hibernate. However, when I run Junit tests and print the stats, it seems there is nothing in cache: OUTPUT OF CACHE MANAGER STATS ON EVERY CACHE: COM.****.SERVICES.CLARITY.DOMAIN.ACTIONITEM.BYRESOURCEUNIQUENAME: getCacheHits: 0 getCacheMisses: 0 getObjectC...

Do you know of any JNI wrapper toolkits or libraries that wrap common linux OS APIs?

I'm looking for a library or toolkit (so I don't have to write it) that will allow me to do common things like the following in Linux: Get the uid for a username. Get user / group membership information. Get information about free space on disk drives. Any other potentially useful API calls that are not normally available in Java becau...

Java and SEO URLS

I'm building a webapp using spring MVC and am curious as to whether there is any clean way to make SEO urls. For example, instead of http://mysite.com/articles/articleId and the such, have: http://mysite.com/articles/my-article-subject ...

Openoffice3/jodconverter stopped working

I have installed Openoffice.org3 on our server and it's running in headless mode. We use it with jodconverter to convert word and excell files. It used to work fine, but one day it just stopped working and I really don't understand why. When I run /usr/local/bin/java -jar jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar on an .xls ...

OutOfMemoryError - why can a waiting Thread not be garbage collected?

This simple sample code demonstrates the problem. I create an ArrayBlockingQueue, and a thread that waits for data on this queue using take(). After the loop is over, in theory both the queue and the thread can be garbage collected, but in practice I soon get an OutOfMemoryError. What is preventing this to be GC'd, and how can this be fi...

Consistency of hashCode() on a Java string

The hashCode value of a Java String is computed as (String.hashCode()): s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] Are there any circumstances (say JVM version, vendor, etc.) under which the following expression will evaluate to false? boolean expression = "This is a Java string".hashCode() == 586653468 Update #1: If you claim th...

hibernate hbm2hbmxml

I am trying to use ant hibernatetool task to generate hbm.xml files from my db schema in mysql. ant task runs without errors but no hbm.xml files are generated. What am I missing... Here are the relevant coonfigurations: build.xml <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="...

BOF at Spring One

What is BOF ? I can see lots of mentions of it but can not find a 'relevant' definition. Bill ...

How to implement a method to return Iterator of files recursively in Java

I want to implement a method like this: public Iterator<File> getFiles(String root) { // return an Iterator looping through all files in root and all files in sub-directories of roots (recursively) } In C#, this can easily be implemented with the yield return keyword. In Java, I suspect I have to end up writing a lot of complicated...

Portal/portlets programming - portlet linking/page flow

I am writing my first portlet based application (for liferay, but the solution should be container agnostic) and I am wondering how people solve to provide links to the user that "lead" to different portlets (maybe on different "pages" in the portal). While you can easily have different view modes inside your portlet, how can you link t...

Selenium RC and clicking on Panel links!

Hi, I'm trying to click on the panel links (links in the same page but different panel) in the page using Selenium RC. I'm able to do it by using: browser.waitForCondition("selenium.isElementPresent(\"id=placeOrderLink\")", "30000") but I want to make it generic and I tried to use: String var="placeOrderLink"; browser.waitForConditi...

Doubt in if/else-if logic

Hi : I am using the following code String sample = " : : "; String[] splitTime = sample.split(":"); if ( splitTime[0].trim().equals("") || splitTime[0].trim().equals(null)) { System.out.println("Inside Split 0"); splitTime[0] = "0"; } else if (splitTime[1].trim().equals("") || splitTime[1].trim().equals(nul...

How to batch insert in specific order?

EntityManager doesn't seem to care in which order to persist entities but I need that. Any ideas? ...

How can split a string which contains only delimiter?

Hi All : I am using the following code: String sample = "::"; String[] splitTime = sample.split(":"); // extra detail omitted System.out.println("Value 1 :"+splitTime[0]); System.out.println("Value 2 :"+splitTime[1]); System.out.println("Value 3 :"+splitTime[2]); I am getting ArrayIndexOutofBound exception. How does String.split()...

problem in implementing dynamic pagesize in pagination strut2 + java

hi i am try to implement pagination through display tag in strut2 now my requirement is i have a combo box which has some page size value like 5, 10, 15 .. so how can i update that value in page size of display tag in strut2 thank in advance regards lakhaman odedra ...

In Java how can I validate a thrown exception with JUnit?

When writing unit tests for a Java API there may be circumstances where you want to perform more detailed validation of an exception. I.e. more than is offered by the @test annotation offered by JUnit. For example, consider an class that should catch an exception from some other Interface, wrap that exception and throw the wrapped excep...

OutOfMemory in Eclipse in a Launched process

I have an OutOfMemory (heap size) in eclipse using a third party plugin The plug in is Adobe Livecycle work bench and during the out of memory the plugin is retrieving via WS (using Axis) a list of around 70 workflow components on my server Here is a extract of my call stack in Eclipse ... at org.eclipse.equinox.launcher.Main.main(Mai...

WCF Interop with Axis2 using WS-Trust

We are trying to get WCF and Java talking to each other using SAML tokens issued from an STS. Despite the fact that both sides are compliant with the standards, WS-Security, WS-Trust, WS-Policy, etc., they don't seem to talk to each other and one or the other will throw cryptic exceptions or ignore security headers. We are using .NET 3....