java

SeleniumException: ERROR: There was an unexpected Alert!

I get this error while running selenium RC tests against IE7. com.thoughtworks.selenium.SeleniumException: ERROR: There was an unexpected Alert! [error:[object Error]] It happens whenever I attempt to click a link or a tab or anything clickable. Any Ideas guys. This is really frustrating. ...

Remoting SWT GUI

I'm trying to remote an SWT GUI (Eclipse RCP) from a Linux or Windows box onto a Windows Mobile handheld device. So far I've tried: RDP: Windows Terminal Services. xrdp server on the Linux box. This works, but we have issues with the clipboard and pasting punctuation (i.e. on the PDA, which has a barcode scanner that copies the barcode...

Most frequently repeated numbers in a huge list of numbers

I have a file which has a many random integers(around a million) each seperated by a white space. I need to find the top 10 most frequently occurring numbers in that file. What is the most efficient way of doing this in java? I can think of 1. Create a hash map, key is the integer from the file and the value is the count. For every numb...

Print string literal unicode as the actual character

In my Java application I have been passed in a string that looks like this: "\u00a5123" When printing that string into the console, I get the same string as the output (as expected). However, I want to print that out by having the unicode converted into the actual yen symbol (\u00a5 -> yen symbol) - how would I go about doing this? i...

Bytecode instrumentation generating java verifier error

Hi, I am using ASM in order to do bytecode instrumentation for Java programs. What I'm doing is simple - When instrumenting a method, if the instruction is a PUTFIELD, simply do a DUP_X1 right before the instruction, then visit the PUTFIELD and inject a function call with an argument that includes the DUP'ed stack entry. ...

In Java, how do I wait for all tasks, but halt on first error?

I have a series of concurrent tasks to run. If any one of them fails, I want to interrupt them all and await termination. But assuming none of them fail, I want to wait for all of them to finish. ExecutorCompletionService seems like almost what I want here, but there doesn't appear to be a way to tell if all of my tasks are done, exce...

how to make a copy-paste script with jcreator?

Hi guys, can u help me with the coding of java, so i can copy a single file using command prompt. so, i wanna run the java file from command prompt of windows, like "java "my java script" "my file target"" and make a copy of my "my file target" at the same directory without replace the old one. please help me? i came out with this im...

Sun Java Tutorials for earlier versions of Java?

Hi, I'd like to read the Sun Java Swing tutorials for Java version 5. It's easy to find Sun's tutorials for SDK 6. My searches of Sun's site and using Google didn't turn up any links (yet) to the older tutorial. Even the tutorial link on the SDK 5 page pointed to the current tutorials. Are the older tutorials still available? If so...

AppEngine datastore: "Object with id ... is managed by a different Object Manager"

I'm using the Google AppEngine, with Java. When I use some datastore features, I'm getting an error message: Object with id "edvaltt.Teacher@64064b" is managed by a different Object Manager I don't know what this means or how to fix it or where to look for documentation on this error. Can anyone help me? The code I'm using is: @P...

What do I need to do in order to distribute a vc++ exe that embeds a jetty web-app?

Hi, I have a pretty basic vc++/vs question, but the googles are failing me. I've seen this question posed before, but none of the proposed solutions work for me. I come from a very high-level language background (java/c#), so these pesky linking issues are alien to me. I appreciate your patience... My problem is that when I send my e...

What does CascadeType.REFRESH actually do?

What does the CascadeType.REFRESH actually do? The definition for it is "When we refresh an entity all the entities held in this field refresh too", but what does this mean in practice? Could someone please give me a simple example? ...

Best java 3D pie chart API

Which is the best java 3D pie chart API available to use in a standalone java application? The pie chart should also support detached property. ...

How to create a thread that runs all the time my application is running

EDIT: I'm now sure that the problem is related to the while (true) loop holding all other commands as I've commented it out and the application deploys without the attached exception. I'm not sure how much it is important but my ServletContextListener implementation looks like this: public class BidPushService implements ...

How can I check if a Java program's input/output streams are connected to a terminal?

I would like a Java program to have different default settings (verbosity, possibly colored output where supported) depending on its use. In C, there is an isatty() function which will return 1 if a file descriptor is connected to a terminal, and 0 otherwise. Is there an equivalent for this in Java? I haven't seen anything in the JavaDoc...

simple symmetric encryption of long to String (and back) in java

Hi, I'm looking for a simple way to translate long to String and back in a way that will "hide" the long value. I'd prefer to avoid adding another .jar to the project for this feature. It does not have to be a hard-to-crack encryption, just to look random to the inexperienced eye. Addition: My purpose here is to attach a counter val...

java.lang.UnsatisfiedLinkError no *****.dll in java.library.path

How can I load a custom dll file in my web application? I tried following ways but its failing. copied all required dlls in system32 folder and tried to load one of them in Servlet constructor System.loadLibrary Copied required dlls in tomcat_home/shared/lib and tomcat_home/common/lib all these dlls are in WEB-INF/lib of the web-applic...

how can I set the log4j conversionpattern at runtime

I have a Java app while parses input from a spreadsheet. I've added the ability to run just the parser part standalone from an ant task. However the normal log4j pattern I'm using can make the output hard to read, I'd like to set a simple pattern at runtime. So something like log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd ...

In what case would a programmer get the webApplicationContext out of DispatchServlet?

I notice that there is getWebApplicationContext in org.springframework.web.servlet.mvc.AbstractController. This means that spring programmers can use getWebApplicationContext to access beans in the spring IoC container. However, I never see people use this way to get beans in all the spring MVC tutorials. So here comes my question, in ...

Output Parameters in Java

With a third party API I observed the following. Instead of using, public static string getString(){ return "Hello World"; } it uses something like public static void getString(String output){ } and I am getting the "output" string assigned. I am curious about the reason of implementing such functionality. What are the advant...

How to implement memcached using a database ?

As far as I know, memcached runs in-memory and does not have a persistent backing-store. Currently my team is not ready yet to use memcached. So, I plan to write a simple database backed alternative. My question is pretty much in similar vein to this other question http://stackoverflow.com/questions/33619/concurrent-logins-in-a-web-f...