java

Running Java bytecode on the Android - Sun JVM on top of DalvikVM

Since both the java implementation (OpenJDK) and Android's virtual machine DalvikVM are opensource it must be possible to implement Sun's JavaVM on top Google's DalvikVM. This would make it possible to run JVM based apps and languages (Clojure, Jython) out-of-the-box on the android. Is there an ongoing effort to produce such an implemen...

How do you kill a thread in Java?

How do you kill a thread in Java? ...

Using variable name as array index

Hi everyone, I have few files which I put in array. I shuffle the files so that it can be displayed in random order. How to know that array index 0 is actually image1.txt or image2.txt or image3.txt? Thanks in advance. String[] a = {"image1.txt","image2.txt","image3.txt"}; List<String> files = Arrays.asList(a); Collections.shuffle(fi...

Is there a Java CalDAV api?

Hi, I want to communication using CalDAV across to my calendar server, any Java API for this? ...

What is the best java web application framework that goes well with xml+xslt?

I recently learned a bit about xml/xslt and would like to try it in my web project. What framework would you recommend for that? Basically, I want to generate a dynamic xml that will be applied to xslt stylesheet on the client side. Wicket was my first candidate, but it is primarily html-centric. Didn't manage to get my idea work yet. ...

How to change timer format

Hi everyone, Ive created timer. How can I change the timer format to second so that it wont be long number? Thanks private long startTime = System.currentTimeMillis(); Timer timer = new Timer(1000, this); timer.start(); timer.stop(); long endTime = System.currentTimeMillis(); long timeInMilliseconds = (endTime - startTime); ...

Reset timer

I have tried to reset the timer based on the current time after clicking a button, but it doesnt work. Help :-( private long startTime = System.currentTimeMillis(); Timer timer = new Timer(1000, this); timer.start(); timer.stop(); long endTime = System.currentTimeMillis(); long timeInMilliseconds = (endTime - startTime); timer.re...

Where can I find a Java decompiler?

http://www.kpdus.com/jad.html#download ? The above link to JAD (a Java decompiler) is not working. Is there any other place where I can find a Java decompiler? ...

Java EE video lectures

There are plenty of java videos and video lectures floating about, but does anyone know of any that deal specifically with Java EE? For my own point of view I'd be more interested in the EJB side of things, but any Java EE lectures would be useful, as well as videos on things like Spring etc. Thanks. ...

How to remove pre-defined characters from user input in a J2EE web application?

we have a J2EE web application usig Spring MVC. We have a new requirement for our web application where we have to remove certain pre-defined characters from the user input. For example, let's say that the application should remove '<' from all the user inputs. I have come up with 2 approaches to meet this requirement : JSP Level : ide...

Unintended consequences of anonymous class created just for sake of adding instance initialization block

This is a question about Java code such as: List<String> list = new ArrayList<String>() {{add("hello"); add("goodbye");}} where the programmer has extended ArrayList anonymously just for the sake of shoving in an instance initialization block. The question is: if the sole intention of the programmer is merely to achieve the same as: ...

How do I make a Java class immutable in Clojure?

I'd like to wrap java's PriorityQueue class in clojure for use in another part of my program. What I'm trying to figure out is if there is any way to do this in a lispy manner and make the priority queue immutable. Are there any good ways to do this, or am I just going to be better off using the PriorityQueue as a mutable data structur...

Java array problems

I have put few elements in array (e.g. 5 elements) The first element, index[0] of the array will automatically displayed without the user need to click the button. After the button clicked, it will print the next elements of array and the processes continue until the last element of array. Everytimes the button clicked, a file will be ...

Hibernate not reflecting changes

I have a struts application that uses Hibernate to access a MYSQL DB. I have a number of pages that make changes to the DB. These changes go through fine, data is update in the DB. However when browsing to the page that should show this updated information its often not there, and even after a few page refreshes it still isn't there. Eve...

Creating a custom Hibernate UserType: find out the current entity table name

I am writing a Hibernate CompositeUserType, and in order to serialize the custom object to JDBC, I need to know the name of the table I am updating (because there is some configuration for my tool attached to the table). The only way I can make this work right now, is to explicitly parameterize my UserType with the entity tablename, wh...

How to access domain classes from src/java in GRAILS?

Hi there! How can I access or better pass on a bunch of domain classes from a controller in Grails to a quite simple java program residing in src/java within the grails tree? I always get a ClassNotFoundException for the domain classes, regardless in which package I put them in. There's no auto-completion pointing to the domain classes ...

Of Swing and AWT, why is one considered light-weight and the other heavy-weight?

Why is it said that Swings is heavy-weight and AWT is light-weight in JAVA? ...

Android: Regaining focus using SurfaceView

I'm currently getting to grips with Android, playing around with the Lunar Lander sample. I've found that if you navigate away from the app (eg, hit the call button) it will destroy the underlying surface (calling surfaceDestroyed). Navigating back (which will trigger onWindowVisibilityChanged) the app will crash, as it will try to dra...

Java Pattern to match any sequence of characters except a given list

How do I write a Pattern (Java) to match any sequence of characters except a given list of words? I need to find if a given code has any text surrounded by tags like besides a given list of words. For example, I want to check if there are any other words besides "one" and "two" surrounded by the tag . "This is the first tag <span>one<...

How to parse GPX files with SAXReader?

I'm trying to parse a GPX file. I tried it with JDOM, but it does not work very well. SAXBuilder builder = new SAXBuilder(); Document document = builder.build(filename); Element root = document.getRootElement(); System.out.println("Root:\t" + root.getName()); List<Element> listTrks = root.getChildren("trk"); System.out.println("Count tr...