java

Spring Transaction Management Test

I want to test my Dao Class using the SpringContextTests. In my method class I extended the AbstractTransactionalJUnit4SpringContextTests in order for my test class to integrate with JUnit4. I have also set up the configurations and made the initialization and database clean up in the @Before and tearDown in the @After. My test class wor...

Create possible pairs irrespective of order in a indefinite set of values.

What i am trying to figure out is an algorithm that will create possible pairs irrespective of order in a indefinite set of values. for example let's say the set is A,B,C,D,E then possible sets are AB AC AD AE BC CD DE but... i also want pairs of more than 2 values. for example ABC ABD ABE BCD BCE but also ABCD or ABCE. The proble...

Is there an easy way to backup Oracle SQL Developer's User Snippets?

I love Oracle SQL Developer so I find myself using it a lot to complete my daily tasks. The thing is that my collection of custom snippets only keeps growing so I though it'd be interesting to learn how to backup them. Before asking blindly I did a bit of work trying to figure out how. I've performed a search within the application's fo...

Synchronizing JTable and JTree

Is there a way for a JTable and a JTree to share the same model, so that any change in that underlying model is reflected immediately in both components ? ...

Java Regular Expression Problem

I have a group of lines like the following: tb-set-node-recipe $vpn1 W2K3_SP2_VPN_SRV tb-set-node-os $vpn2 I_W2K3_SP2_VPN_SRV tb-set-node-os $xpcli1 I_XP_SP3_VPN_CLI tb-set-node-os $xpcli2 I_XP_SP2_VPN_CLI tb-set-node-os $xpcli3 I_XP_SP1_VPN_CLI tb-set-node-recipe $ftp1 FC8_KS_FTP_SRV tb-set-node-os $smb1 XP_...

Should I add support for PropertyChangeSupport and PropertyChangeListener in a Java bean for a web application?

I noticed that some people write beans with support for the Property Change observer pattern. import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.Serializable; public class SampleBean implements Serializable { public static final String PROP_SAMPLE_PROPERTY = "sampleProperty"; priva...

Difference Between Equals and ==

What is the difference between a == b and a.Equals(b)? ...

How do I import a directory (and subdirectory) listing in Java?

Here is the code I have thus far: import java.io.*; class JAVAFilter implements FilenameFilter { public boolean accept(File dir, String name) { return (name.endsWith(".java")); } } public class tester { public static void main(String args[]) { FilenameFilter filter = new JAVAFilter(); File directo...

How can I visualize jar (not plugin) dependencies?

I am currently refactoring a large Java application. I have split up one of the central (Eclipse) projects into about 30 individual "components", however they are still heavily inter-dependent. In order to get a better idea of what depends on what I am looking for some way to graph the compile time dependencies. All tools I have found s...

Advantages/disadvantages of writing a web app using Adobe Air/Java as opposed to platform specfic languages?

I need to write a web app (that also works offline) for windows and mac (and linux as well perhaps). I was wondering if I should use something like air/flash/java for this, the advantage being I will only need to write the app once. However, I was wondering if there are any disadvantages of doing it that way as opposed to ...

What is a scripting language that understands datatypes and can be implemented in Java?

I am looking for a scripting language that meets the following criteria: Well Documented Implemented in Java Understands Datatypes (can handle longs, strings, etc) Is fully extensible Any suggestions? Currently, I'm using Javascript, but the Doubles that it sets numbers to is not big enough for the data work I'm doing. Thanks! ...

Trouble making obfuscation

I'm using Antenna to build, pack and obfuscate a j2me app. Building and packing works fine. The project uses a 3rd party jar that is already obfuscated except by some interfaces. When trying to obfuscate I got several errors like: [wtkobfuscate] Warning: i: can't find referenced class fooPackage.fooClass Class i and fooPackage.fo...

Zero-padding a spinner in Java

How do you add zero padding to a JSpinner? Since the spinner creates the JFormattedTextField itself, I can't just pass the format into the JFormattedTextField constructor. Isn't there a way to set the formatting on an existing JFormattedTextField? What I want: value = 37, editor = "0037" UPDATE: I have tried this as suggested: JSpin...

Running Two Versions of Java JDK

I primarily use JDeveloper 10 with JDK 1.4.2 on Vista. I would like to install Eclipse and have it run the latest JDK 6. Is this possible without conflict? Ideally I would like to just use JDeveloper and switch back/forth between JDK versions. Is this possible? ...

When, typically, do you use == equality on a reference typed variable in Java / C#?

As a kind of follow up to the question titled "Difference Between Equals and ==": in what kind of situations would you find yourself testing for reference equality in Java / C#? ...

Is there a way to generate the 8.3 or 'short' (Windows) version of a file name in Java?

In our application, we are allowing users to open files and directories. Java 6 provides us with... java.awt.Desktop.getDesktop().open(file); which works great. However, since we need to ensure Java 5 compatibility, we also implement a method of opening files by calling the start command in cmd.exe... String command = "cmd.exe start...

Replacing build.xml with Build.java - using Java and the Ant libraries as a build system

I've grown disillusioned with Groovy based alternatives to Ant. AntBuilder doesn't work from within Eclipse, the Groovy plugin for Eclipse is disappointing, and Gradle just isn't ready yet. The Ant documentation has a section titled "Using Ant Tasks Outside of Ant" which gives a teaser for how to use the Ant libraries from Java code. ...

Java noob question - how to store a string to a new text file

Here is my scenario: Selenium grabbed some text on the html page and convert it to a string (String store_txt = selenium.getText("text");) - the text is dynamically generated. Now I want to store this string into a new text file locally every time I run this test, should I use FileWriter? Or is it as simple as writing a System.out.prin...

Why Use java.io.Console?

Just a quick one here. What are the benefits of using java.io.Console as opposed to using a BufferedReader wrapping an InputStreamReader for System.in? Why would I use it? Thanks for any advice! ...

Setting messages.properties in a Spring Webflow unit test

I'm using Spring Web Flow 2.0.7, and just started setting up my unit tests. I've got my flows directory, containing the flow xml files and my messages.properties files on my classpath. It's loading fine, but it doesn't seem to be automatically picking up the messages.properties file for the flow, and thus my validation unit tests are...