java

clear() methods in Java

Many of the container type data structures in Java come with a clear() method. For example, we can call clear() on a Vector we want to clear out all the contents in the Vector. My question is after applying the clear() method, does the content in the vector get nulled out or are they still being referenced? Thanks. ...

Extracting two numbers from a string

I have a String like the following one: "some value is 25 but must not be bigger then 12" I want to extract the two numbers from the string. The numbers are integers. There might be no text before the first number and some text after the second number. I tried to do it with a regexp and groups, but failed miserably: public Mes...

Is the following utility class thread-safe?

First let's look at the utility class (most javadoc has been removed to simply the example): public class ApplicationContextUtils { /** * The application context; care should be taken to ensure that 1) this * variable is assigned exactly once (in the * {@link #setContext(ApplicationContext)} method, 2) the context is...

How can i monitor system statistics in kubuntu using Java?

i am doing a project related to configuration and memory analyzer for kubuntu. i want to display the system statistics information like CPU usage, RAM usage and proceses etc. graphically using an odometer. i wanted to know if there is any great open source library for graphical component like odometers and other graphing utilities. also...

Buliding a WAR that uses Axis2 + Rampart for Tomcat

I'm trying to build an axis-based web service with rampart for security, and I've been hoping to deploy a single war to tomcat, rather than installing axis and deploying within axis. (I'm not fixed on that though... this is all very new territory for me, so I could use any feedback that you might have.) I'm running into a few problems:...

Generating correlated numbers

Here is a fun one: I need to generate random x/y pairs that are correlated at a given value of Pearson product moment correlation coefficient, or Pearson r. You can imagine this as two arrays, array X and array Y, where the values of array X and array Y must be re-generated, re-ordered or transformed until they are correlated with each...

Java executable jar. What does this piece of code do?

I am looking at Yahoo's YUI compressor executable jar and they have this class, linked from Manifest file as "Main-Class": package com.yahoo.platform.yui.compressor; import java.lang.reflect.Method; public class Bootstrap { public static void main(String args[]) throws Exception { ClassLoader loader = new JarClassLoader()...

toString(), equals(), and hashCode() in an interface...

So, I have an interface with a bunch of methods that need to be implemented, the method names are irrelevant. The objects that implement this interface are often put into collections, and also have a special toString() format that I want them to use. So, I thought it would be convenient to put hashCode(), equals(), and toString() into ...

How to disable Google Visualizations Select "balloons"?

Does anyone know how to disable the little "detail" balloons that popup when a Google Visualizations' chart is clicked (Selected)? Following the sample code at Getting Started with Visualizations, my charts look wonderful except that the "zoom details" feature I've developed don't override the default balloons. Unfortunately the balloo...

need help with java applet which uses external jar ojdbc6.jar

I have wrote a java applet which is pretty simple. It connects to a oracle database upon clicking a button. It works fine, it connects when I run it using eclipse. However, when I use ant to create the jar file I dont know how to include the ojdbc6.jar as a classpath. Can someone please help me? Ive been trying for a week now. Here is ...

reusing socket channels

im trying to implement a client app with an asynchronous connection. i want to know if i can reuse a SocketChannel object after it has failed to connect to a server. SocketChannel channel = SocketChannel.open(); channel.configureBlocking(false); InetSocketAddress addr = new InetSocketAddress(host, port); SelectionKey key = channel....

Replay a non-looping gif image

I've got a non-looping gif that I use as ImageIcon for two JLabels, but not at the same time. My problem is that when I set the second JLabel's icon to be the gif, the animation has already been played, so it only show the last frame of it. Do you know a way to get the animation when the gif is set to the second JLabel? ...

Need Help With Java Code...HTML Parser Cannot Be a Resolved Type

Hi, I have this java source code which one of my friend gave me and unfortunately he is away from the country to fix my issue.This code,scrapes the data from the websites and fills the database it self. But previously due to some layout changes in the website,it is not functioning properly.So i am giving a try to recompile it using ecl...

Communicating between Adobe Air or browser and Java Web Start

We're designing an application and the client has requested that a portion of their app stay in Java Web Start and another portion be in a browser. I'm thinking about AIR as an alternative to the browser because that may give us more features b/c we don't have to stay in the browser security sandbox. How would I go about having an Air ...

How are VTBLs implemented in Java?

Running this code: class A { public int x; public A() { function(); ...

Java Ant: How to setup "apply" task with allowing file overwriting?

My command line app call looks like this: java -jar myapp.jar --output c:\test.txt c:\test.txt Which reads test.txt, processes it and saves result to the same file. I am trying to make ant task out of it but can't figure out how to make it use same path for input and output. <target name="compress"> <apply executable="ja...

Is there a problem initializing a JAXBContext with a package in a library?

I'm trying to initialize a JAXBContext like so: JAXBContext jaxbContext = JAXBContext.newInstance("ebay.apis.eblbasecomponents"); When the code is run, however, I get the following run time error: Exception in thread "main" java.lang.NoClassDefFoundError: ebay/apis/eblbasecomponents/ObjectFactory Caused by: java.lang.ClassNotFoundExc...

Can JSF 2.0 be used with Websphere application server version 7.x

Can JSF2.0 be used with Websphere application server version 7.x ...

VisualVM memory leak detection

I am trying VisualVM for detecting memory leak in java. I am using the version 1.2.1. I took two snapshots to try to capture the change of memory usage overtime. In a tutorial I read, it says that one can select there two snapshots and right click and select "compare". I followed this instruction, but could not find a "compare" option, I...

Making a JButton stay depressed manually

I would like to make a JButton stay pressed down and not be able to be pressed again until some event occurs is there an easy way to do this? ...