java

Help making a JTree with a JCheckBox

Hi -- I have an unusual situation where I need to have a JTree with each node containing 2 checkboxes and a label (with the ability to add a listener to tell when any of the potential checkboxes are checked). I also need the root node to have the same layout (which I'm assuming means creating a JPanel with 2 JCheckBoxes and a JLabel), wi...

Java Hashmap: Swap two values?

Can I swap the keys of two values of a Hashmap, or do I need to do something clever? Something that would look something like this: Map.Entry<Integer, String> prev = null; for (Map.Entry<Integer, String> entry: collection.entrySet()) { if (prev != null) { if (entry.isBefore(prev)) { entry.swapWith(prev) } } prev = ent...

ORA-01000: maximum open cursors exceededwhen using Spring SimpleJDBCCall

We are using Spring SimpleJdbcCall to call stored procedures in Oracle that return cursors. It looks like SimpleJdbcCall isn't closing the cursors and after a while the max open cursors is exceeded. ORA-01000: maximum open cursors exceeded ; nested exception is java.sql.SQLException: ORA-01000: maximum open cursors exceeded spring The...

Dynamically loading a Jar file will not work; have tried a lot

Hi, my app basically stores a jar file in a "Blob" in mysql and then grabs it through a PHP file. This is not a problem, because doing: $ wget http://path/to/php $ jar tf file.jar shows the classes perfectly fine. I have tried many things, and the farthest I've gotten is when using ClassLoader.loadClass() when I call newInstance() it...

How to synchronize access to ehcache, memcached & other key-value stores ?

From my understanding, each of these methods: get() and put() are atomic. But, when accessing caches like ehcache & memcached, in a CheckThenAct fashion, race conditions will arise. What should we synchronize on to ensure that if thread1 does a Get() and thread2 does a Get() followed by a Put(), that the first Get() will receive the ne...

How to parse/leach/extract a ASP.net website Content using Ruby or PHP or Java?

Hi , I am doing a hobby project to scrape the content of an ASP.net website using Ruby or PHP or Java . For example if the website url " www.myaspnet.com/home.aspx" . i would like to extract the unicode text content from home.aspx and paste it to a notepad . Is there any libraries available in any of the above mentioned languages ...

Is Interface as labels a bad practice in java OO?

During the parsing of certain xml files, I come across a situation that I have to use interface as labels to identify that certain tags belong to certain category, for example, I created a Tag interface to identify that these classes are used to represent xml tags, and ContainableTag to point out that certain tags can be one of the child...

What's your deep comprehension of pointer,reference and Handle in C,C++ and Java?

What's your deep comprehension of pointer,reference and Handle in C,C++ and Java? We usually think about the pointer,reference and Handle on the specify language level, it's easy to make confusion by the newbie like me. Actually all those concept in java, just a encapsulation of pointer. All pointer just a encapsulation of main memory...

Turn Off Apache Common Logging

Hi, I am using Apache Common Logging library in my standalone application. After searching through the web, I try to turn off the logging by using package javaapplication1; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * * @author yccheok */ public class Main { /** * @param args ...

Unwanted jar files in tomcat/lib or WEB-INF/lib

I am currently working on an application which is around a decade old. When I looked in to the jar files which are associated with the application , I can see lots of jars which are not required and lots of different versions of same jar. What are the cons of having unwanted jars in lib. What is the easy way to find and remove them? ...

Which Java web development framework for an AJAX application?

I read through a few threads (simple web framework, java web development, etc). Very informative. However I have not seen a focus on the AJAX side of things. For the app I am trying to create, most of the client side will be written in Google GWT, and JSON will be used to communicate with the server side. In that case, all templating is ...

Multithreaded chat-server in Java

I'm trying to implement a server-client socket program in Java that can support multiple clients, but my class that performs the multithreading always crashes whenever my client connects to my server. import java.io.*; import java.net.*; public class ClientWorker extends Thread{ Socket cwsocket=null; public ClientWorker(Socket...

Sending int through socket in Java

What is the best possible way to send an int through a socket in Java? Right now I'm looking at sockout.write((byte)( length >> 24 )); sockout.write((byte)( (length << 8) >> 24 )); sockout.write((byte)( (length << 16) >> 24 )); sockout.write((byte)( (length << 24) >> 24 )); and then trying to rebuild the int from bytes on the other s...

wav to speex conversion taking alot of Time

HI, I am using Jspeex Api to convert a .wav file into .spx file, everything goes perfect when tested on desktop it took only 2 seconds, Android developer used the same code but they took around 3 minutes to encode the same file on their simulator & Phone. Is there any way to reduce this time for encoding? Code used to convert is as foll...

how to stop selenium server on click of button using java ?

i have three projects generictest, testcase and testframework here generictest contains all the utility of selenium control. testcase contains all the testcases using junit and execute with selenium server and testframework show the qa dashboard it having two button start execution and stop execution and list of all testcases which are a...

Reload Kerberos config in JAVA without restarting JVM

Hello, The following code is for authenticating to a windows AD server using Java+Kerberos and it works fine- public class KerberosAuthenticator { public static void main(String[] args) { String jaasConfigFilePath = "/myDir/jaas.conf"; System.setProperty("java.security.auth.login.config", jaasConfigFilePath); String krb...

Single or multiple thread pools for Java server?

I am writing a fairly complex Java server application which has a significant background processing portion in addition to the usual request-response processing. Some of the background processing is done in a cron-like fashion using Quartz framework. Other tasks are more of on demand - if a new client connects it creates additional job f...

Dynamically loading name of Java class file in a Quartz job

I have a Quartz job written in Java which runs fine if I have the Quartz JobDetail line set as follows: JobDetail jd = new JobDetail("FeedMinersJob", scheduler.DEFAULT_GROUP, FeedMinersScheduler.class); But I would like to dynamically load the class because the job details are stored in a database table. So I want something like this...

Sharing objects across Java processes

I am executing another JVM (java.exe) from the main application. Is there any way to share an object (rather large object) with the newly created process (at the time of creation or after it was created). someObject sO= new someObject(); //sO is populated //Creating new process Runtime rt = Runtime.getRuntime(); Process proc = rt.exe...

Java tool tip not displaying.

The program I am writing has a Swing GUI and several of the components have Tooltips. These are all on JButton, JCheckBox and JRadioButton components, they are set using the setToolTipText method and all work perfectly. I have just tried to add one to a custom component that extends JPanel using the same method and no tool tip appears. T...