java

Align an image in a SWT TableViewer

Hey Folks, I just found out, that its somehow impossible to align an image in a swt tableviewer. Creating a TableColumn with SWT.RIGHT (for instance) has no effect on that column if its labelprovider returns an image for it. Question: Is there any other way to align an image instead of modifiying the image file itself and put some extra...

Which is the best approach?

I have a question regarding struts. I have a HashMap which has nearly 50 entries. Now I have to define this map inside an action class, say TestAction. As you know, this action class extends the Action class. Now my doubt is fundamental: Should I load the map as static? What are the advantages of loading this Map static? If I am g...

Apache Commons SCXML State Machine Framework

Hello I'm attempting to define a state machine for a Java application using Apache SCXML. However, I've run into a problem and I'm not sure if this is due to the SCXML framework or me doing something wrong. I'm basing my test application on the following example (without the android bit): http://commons.apache.org/scxml/usecases/scxml-s...

How does Integer.parseInt(string) actually work?

Was asked this question recently and did not know the answer. From a high level can someone explain how Java takes a character / String and convert it into an int. Many thanks Karl Edit: Would also be good to know if other languages do a similar sort of thing as well. ...

Displaying left/right stereo activity while capturing audio from microphone (JAVA)?

I am trying to analyze the microphone input through Java so you can graphically display where the sound is coming from around the computer. I have audio capture code working well (from: http://www.developer.com/java/other/article.php/1565671#Complete%20Program%20Listings) and have tried to implement: (FloatControl) targetDataLine.getCon...

Want to invoke a linux shell command from Java

I am trying to exec some linux commands from Java code. Actualy the code that I use is useing redirection (>&) and pipe simbols (|). How my Java code should be to be able to invoke that command as in csh or bash. Thanks in advance. P.S. I have used: Process p = Runtime.getRuntime().exec("shell command"); but this code is not OK with...

How do I dump a MySQL database using ant?

I couldn't find any information about how to dump a MySQL database with an ant task. Do I have to create my own task to do this? ANT script ===generate==> myDataBase.sql ...

Problem in understanding cstutoringcenter problem 43 solution bug

Problem: How many of the first 100,000,000 hexagonal numbers are divisible by all the numbers from 1 through 20? 2nd solution - simple brute force (does work) public static void main(String[] args) { long hnr = 100000000L, count = 0L; for (long i = 1, h = getHexNr(i); i <= hnr; i++, h = getHexNr(i)) if (h % 2 == 0 && h % 3 ==...

Wicket directory structure

Hey! I'm trying to figure out the directory structure of wicket. I don't get it at all! Let's say I wanna load an image with images/logo.gif or something like that. Where do I have to place the images folder? Please help me with this! ;) ...

How does Java's System.exit() work with try/catch/finally blocks?

I'm aware of headaches that involve returning in try/catch/finally blocks - cases where the return in the finally is always the return for the method, even if a return in a try or catch block should be the one executed. However, does the same apply to System.exit()? For example, if I have a try block: try { //Code System.exit(0...

Dynamic create WHERE clause from user Search criteria

I have what I'm sure is a fairly common issue, and I don't want to re-invent the wheel. I have a search form where users can specify search criteria and type of search (AND OR Ext..). The form passes back id's that map to column names and values. Currently, I'm using server side Java to glue the strings together into a where clause. It...

Connecting to remote server using java and ssh key

Does anyone have any code for connecting to a remote server using java and an ssh key. We dont have a password for this server, we just use our username and our ssh keys ...

How do I compare two longs as unsigned in Java?

I'm storing bit patterns of unsigned 64-bit numbers in a long variable and want to calculate the distance between two of them on the unsigned range. Because Java interprets long as a two's complement signed integer, I can't just do a - b, as the following example shows: // on the unsigned range, these numbers would be adjacent long a = ...

javac command under mac terminal output garbled

when I compile java file under mac terminal,output is garbled,how to solve it?(my OS language is chinese) ...

Ensuring serial processing of JMS messages in an OC4J cluster

We have an application that processes JMS message using a message driven bean. This application is deployed on an OC4J application server. (10.1.3) We are planning to deploy this application on multiple OC4J application servers that will be configured to run in a cluster. The problem is with JMS message processing in this cluster. We...

JavaHelp Handler for Hyperlinks?

Using JavaHelp, is there any way to specify/register a custom handler to handle the event of someone clicking on a link in the help page? ...

ServletContext.getRequestDispatcher() vs ServletRequest.getRequestDispatcher()

why getRequestDispatcher(String path) of the ServletRequest interface cannot extend outside the current servlet context where as getRequestDispatcher(String path) of the ServletContext can use the getContext(String uripath) method to obtain RequestDispatcher for resources in foreign contexts. and how?? Please...

Reading string value from Excel with HSSF but it's double

Hi, I'm using HSSF-POI for reading excel data. The problem is I have values in a cell that look like a number but really are strings. If I look at the format cell in Excel, it says the type is "text". Still the HSSF Cell thinks it's numeric. How can I get the value as a string? If I try to use cell.getRichStringValue, I get exception; i...

Javadoc Inserting UML Diagrams

Is there a way to embed images into my JavaDoc? Basically i want to include some UML diagrams explaining the hierarchy of my classes in some of the documentation. Thanks! ...

IntelliJ: configure several Tomcat configurations with different server.xml

In IntelliJ, I would like to have different configurations to start several Tomcat instances, but with different server.xml config files. Is there a way to do this? ...