java

How to restart transactions on deadlock/lock-timeout in Spring?

Hi, What is the best practice on implementing a transaction restart upon deadlock or lock timeout exceptions when using Spring (specifically the Spring recommended approach: declarative transactions) ? Thanks, Asaf ...

How to check if String value is Boolean type in Java?

I did a little search on this but couldn't find anything useful. The point being that if String value is either "true" or "false" the return value should be true. In every other value it should be false. I tried these: String value = "false"; System.out.println("test1: " + Boolean.parseBoolean(value)); System.out.println("test2: " + B...

Looping Forever

I'm trying to loop an exception, but for some reason its not giving me the option to re write my scanner file: I don't know how to use BufferedReader so that's why I'm using this. Any clues? Here's my standard class with my method package arrayExceptionsWithInput; import java.util.*; public class GetThoseNumbersBaby { int firstI...

Is there a Java program snippet which can compile at Java level 5 but not level 6?

I want to have a source file which can compile with javac / ecj set to Java 5 but not Java 6 (even if the underlying Java runtime is Java 6). This is to be certain that the compiler level is set correctly in Eclipse 3.5 running with Java 6 installed, but where the result needs to run on a Java 5 installation. For java 1.4 I could use "...

Loading Image in Java Applet

When I try to run an applet in applet viewer it is not able to find resources (Image). I try to load resource like this: String cb= this.getCodeBase().toString(); String imgPath = cb+"com/blah/Images/a.png"; System.out.println("imgPath:"+imgPath); java.net.URL imgURL = Applet.class.getResource(path); but when i run it in appet viewer ...

about python script excution

I am using TelnetService API in that I am providing the cisco IOS commands similar to Adventnet simulator . I am developping this in eclips environment. To run the python script I gave the command Runtime.exec(java -jar jython.jar scriptname.py); It is returning the error Could not create the Java Virtual Machine.,Unrecognized option...

Code generation for composition using Eclipse

Effective Java, along with other sources suggest that we should consider using composition over inheritance. I have often found my self achieving such composition by using the Decorator pattern and implementing forwarding methods that delegate invocations to a wrapped object. However, I often find myself writing many simple forwarding ...

Complete list of API changes between 1.5 and 1.6 Java

Hi, I was looking for a list of changes in the API between java 1.5 and 1.6, but I couldn't find it. I need cause I used 1.6 for development and sometimes the code needs to be deployed to server that has only 1.5, and I need to check if I've used some new features (e.g. String.isEmpty and similar). Besides just checking if the code work...

Java : How to create a function that can only accept object which is an Interface?

I need to write a function that accepts an object , but I want to enforce in the function call (not after the function is called) that the object is an interface. Meaning , I want to make sure this is an Interface at compile time , not on run time. What do I mean? interface ISomething {...} class A implements ISomething { ... } ISo...

Generate unique key in Java to be used as primary key in Oracle tables.

I am trying to get a string of length 15 to be used as primary key in database tables. The following code in java returns some key with length 35 UUID.randomUUID().toString() Can I change it to return a key of the length 15 ? How to ensure thread safety? Any help is greatly appreciated. ...

jsp:how to hide folder structure of website from users?

how to hide folder structure of website from users. i have developed a website on jave platform (jsp). website is deployed on jboss. suppose my website 's home page url is dummy.com/dummyFolder/dummy1.jsp user can watch all of jsp pages in website by going on url dummy.com/dummyFolder/ what should i do to prevent user to view my ...

Yahoo Finance API

I want to implement the Yahoo Finance API into my web web-application but when I searched for the API, I didn't get the link to the API, rather I found the rss feeds that Yahoo provides for finance data. So, my first question is whether Yahoo provides its Finance API? If yes, the what's the link to that API. I have used several APIs of...

Is it possible to debug core dumps when using Java JNI?

My application is mostly Java but, for certain calculations, uses a C++ library. Our environment is Java 1.6 running on RedHat 3 (soon to be RedHat 5). My problem is that the C++ library is not thread-safe. To work around this, we run multiple, single-threaded "worker" processes and give them work to do from a central Work Manager, also...

Easymock partially mocking (EasyMock ClassExtension), good or bad?

I have written quite a few Mock objects using EasyMock. However, often i find writing partial mocks time consuming, and it does not feel 'right'. I'd say its a design fault as my class I try to mock has multiple concerns into one, therefore I should create seperate classes in order to seperate concerns. What do you think? Is partially ...

i want to create a hashmap from a hashmap with innermap and outermap relationship?

public interface InnerMap<V> extends Map<String, V> { Map<String, V> getInnerMap(String prefix); } For example: baseMap.put("aabb", "one"); baseMap.put("aabbddd", "two"); InnerMap map1 = baseMap.getInnerMap("aa"); map1.get("bb") => "one" map1.get("bbdd") => "two" map1.get("aa") => null map2 = map1.getInnerMap("bb"); map2.get("dd")...

RAD - Websphere Application server won't start

I am having issues with RAD7. My server will not start for me today. I am working from home and connected to the VPN. Everything works except my server in RAD. It worked fine yesterday in work and had previously worked when I was at home but that was a few weeks ago. Are there any settings that I should look out for? I have disable...

How to serialise an antlr3 AST

Hiya, I have just started using antlr3 and am trying to serialize the AST output of a .g grammar. Thanks, Lezan ...

JList item : changing the vertical alignement

My application is using a JList to display numerical values. Here is the default display : +-----------------+ |value 1 | |value 2 | |value 3 | | | | | | | | | +-----------------+ I would like to change the vertical alignement, so that the valu...

How do I find out what jar files are actually used when compiling a java project.

I'm currently passing a very large classpath to javac to compile a java project. I know that a number of those jar files aren't needed. Is there a simple way of finding out which files aren't needed? ...

Running a PHP webapp from Java

I'm interested in running a PHP web application using Quercus in a way similar to: java -classpath ... com.example.LaunchPHP {php folder} All the documentation I could find on Quercus was related to running from Resin, but this is something I want as simple as possible, for running from a CI build. What possibilities are there? ...