java

how to destroy thread in java after the completion of task

Hi, I am using thread pool for my task. After completion of each task i am destroying the thread using Thread.stop() and Thread.destroy(). But after running my application (in eclipse) for around 30 min. i am getting Memory out of bound error . So pls suggest me how to kill the thread. ...

Signed Unsigned Applets / Java Web Start, Socket Connections?

Hello There, I have been developing a test framework for a particular client/server product (COTS) that exposes XML requests & responses via a raw ip socket. I have been able to develop my test framework in a PHP application with good results, but my desire is to make the test framework easily portable. Sure a VMWare image is portab...

java: adding values to a map by multiple threads (is it possible ?)

is it thread safe to add elements to a Map by multiple threads at the same time ? Like if 10 threads add an element to a Map at exactly the same time, is the Map going to have 10 elements or 1 ? UPDATE: I don't need to iterate through this map, all I need is to add, remove and get elements by key ...

Call Groovy Closure from Java Class - Will it Compile?

I have some legacy Java code inside which I'd like to call a groovy Closure. Is this something that the Java / Groovy cross-compiler will be able to handle? I suspect it compiles Java first, but does it do another pass over the Groovy bytecode to resolve all the java references. Or do I need to compile the class with closure first...

C# generated proxy method different than original Java service method

Hi, I have a Java service that has the following method signature: @WebMethod(operationName = "getContactList") public MyListClass getContactList(@WebParam(name = "myList") MyListClass myList) throws IllegalArgumentException { return myList; } public class MyListClass implements Serializable{ Lis...

Define constraints on the context in which as class is instantiated

I wonder if there's a way to define a class in such a way that instances of it will never be members of another class (only local variables), or the other way round - only members but never local. Is there any way in which a class can dictate the scope of it's prospective instances? ...

IE8 losing session details

I have a Java web app that intermittently loses session data. The problem only occurs with users on IE8. I have used IEWatch to monitor the http traffic, and it seems that the correct session cookies are being sent (JSESSIONID2). When the request gets to the server the session has become unbound from the custom session monitor (this use...

External entity in XML causing null pointer exception during DocumentBuilder.parse("file");

Hello All, I was trying to parse a XML Document using DOM Parser. I got null pointer exception while executing doc = builder.parse(xmlDataFile); There were few entities in the XML data file. On removing a particular entity, i was able to parse the file successfully The entity was some thing like this <!ENTITY SAMPLE.TIF SYSTEM "S...

How to convert a UTF-8 byteOffset into a charOffset for a Java String?

I have a byte offset for a byte array containing a UTF-8 encoded string, how can I transform that into a char offset for the corresponding Java String? NB. this question used to read: I have a byte offset into a standard Java String, and I would like to convert that to a character offset. In practice this will mean a method like charO...

java thread safe code + an atomic method question

I have a class Manager that is going to be accessed by multiple threads at the same time, I want to know if I did it the right way ? also I think I need RemoveFoo to be atomic, but I'm not sure public class Manager { private ConcurrentHashMap<String, Foo> foos; //init in constructor public RemoveFoo(String name) { ...

JPA @VERSION how to use it?

@Entity public class Person { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; private int salary; @Version private long version; // ...getters and setters } may i know is there required to create set/get for "version" ? in my code ,when persist (saveorupdate) this entity with hiber...

autmatic turnng off of the monitor when computer is locked.

hi, I want to write a program in java such that as soon as the computer is locked by pressing (ALT +CTR+DEL -> lock comp ) the monitor becomes off.I want to implement this is java. Also when user presses any key of keyboard the monitor shold be on. How can i do this? I want to save the electricity by doing this and make save environm...

How to set the browser locale for Selenium tests running in Java?

I've been looking for a while and still haven't found anything. When I run my Selenium tests from within Eclipse, it opens up a Firefox browser which always has English as its default locale. Changing default browser settings doesn't change the fact that each new browser opened by Selenium has an English locale. I haven't found any way ...

Concurrecy issues with multiple instances of an object

Hi, the documentations always deals very explicitly with the issues of using one instance of an object with more than one thread. However what do I need to know when there are some threads that have their own instance at the same time? Which interference could occur? How do I handle members like SimpleDateFormat that are quiet expensive...

How to set/get profile data with XMPP using Smack

I am working on a XMPP client on Android, using the Smack library. The roster/messaging/presence stuff is running very well. However, I didn't find a way to store additional profile information (userpicture, the dogs name, ...). The only way I see from googling is using VCards. But it simply did not work. I tried the following: VCard...

Spring - handle multiple forms submit with one controller

Is it possible to have one controller to handle multiple forms in spring? For example, i have 3 steps registration that map with "/register" url. Is it possible to have only one RegisterController that can handle all registration's steps form submit? ...

Library for writing XMP to a multipage TIFF

Hi guys, Can you recommend a library that lets me add XMP data to a TIFF file? Preferably a library that can be used with Java Cheers Nik ...

Java programming

I have been reading Herbert Schildt's Java 2: The Complete Reference. To get a complete feel of Java I wish to start with programming assignments. Any suggestions as to where I can find some good assignments? Mainly regarding applets. ...

Using Quartz jobs with pre-created objects

I'm using Quartz(1.6.6) , and it's a great system , but one things really bugs me - I want to be able to use non - default constructor for my jobs. (Yes , I've tried the JobFactory , but I don't like this solution. See below) Meaning- Instead of : JobDetail jobDetails = new JobDetail(jobUniqueName, JOBS_GROUP, CrawlJob.class)...

Why is UncaughtExceptionHandler not called by ExecutorService?

Hi, I've stumbled upon a problem, that can be summarized as follows: When I create the thread manually (i.e. by instantiating java.lang.Thread) the UncaughtExceptionHandler is called appropriately. However, when I use an ExecutorService with a ThreadFactory the handler is ommited. What did I miss? public class ThreadStudy { private st...