java

In java how do you refer to a class that is in the default package of a third party library?

I have downloaded a third party library and they have classes I need to refer to in the default package? How do I import these classes? ...

SoapAction Issue under Java 1.3

This problem has been bothering me for days. Hopefully someone has come across this before and has developed a workaround. So I've developed a middleware Java app which during its execution invokes a SOAP action. Now, the behavior of this bit of code under the 1.6 JDK is working well: // inside a try-catch block SOAPCon...

Java - Reg expression using groups

From a string, I need to pull out groups that match a given pattern. An example string: <XmlLrvs>FIRST</XmlLrvs><XmlLrvs>SECOND</XmlLrvs><XmlLrvs>Third</XmlLrvs> Each group shall begin with <XmlLrvs> and end with </XmlLrvs>. Here is a snippet of my code... String patternStr = "(<XmlLrvs>.+?</XmlLrvs>)+"; // Compile and use regular e...

How to relate ga:campaign and ga:pagePath (content) on Google Analytics Export API?

Using custom reports you are able to drill down on a specific campaign and then choose the Landing Page or content page that the individual visitor choose. When I try to retrieve the same information through the Google Analytics Export API, I get an error if I try to relate those two dimensions in my feed. Is there any success story ab...

(Java) Good Libraries and What they are.

Lets compile a list of 3rd party java libraries that we like and/or find useful. I will post my choices as a reply ...

JPQL test if value is in an array

I was trying to do something that apparently doesn't work in JPQL: JPQL: select c from Car c left join fetch c.owner where c.type in (?1) order by c.model Code: public List<Car> findCarsFilterByTypes(CarType[] types) { return (List<Car>) this.entityManager.createNamedQuery("dealership.findCarsFilterByType...

Is there a way to reload/refresh a java applet from within the applet itself?

I have a button on my applet (contained in a browser) that I would like to make reload or refresh the entire applet one of two ways: Refresh the applet itself without having to refresh the browser Refresh the entire browser Is this possible from within the applet? ...

Switching Writers on an OutputStream in Java

I have one method that opens a file and passes off to another function to write some data to it. That second method wants to use PrintWriter to write its data. However, I didn't want to require that everybody use PrintWriter to write to that stream. Currently it looks something like this ( sanitized example... don't bother criticizing m...

String.contains in Java

String s1 = "The quick brown fox jumps over the lazy dog"; String s2 = ""; boolean b = s1.contains(s2); System.out.println(b); I run the Java code above, the b return true. Since s2 is empty, why does s1 contains s2? I check the Java API, it write: Returns true if and only if this string contains the specified sequence of char values...

Eclipse 3.5 switching tab is very slow

I am using eclipse 3.5 (cocoa build) on Macos 10.5 with Java 1.5.0.19. I just have 3 java files opened 1 files ~ 2000 lines the other 2 are ~ 700 lines. But when I switch from 1 file tab to another, eclipse takes a long time (~ 20 seconds) to switch to another tab. I have already change the eclipse.ini to more eclipse.ini -startup ....

globally disable enter/return key in a SWT dialog

I've created a dialog class filling some common widgets, like text, combo, and tree. It annoys to have the default behavior to dismiss this dialog (same as the default 'OK' button is pressed) when enter/return is pressed whichever widget I was in. To prevent this behavior, I have to add a traverse listener for each widget to filter the ...

Java Webstart Options

I am using javaws to run an application in OS X 10.5.7, Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211), and it seems that the command line arugments are broken in os X. I run the following command in linux and it works fine. javaws -wait -J"-Djavaws.package.runtype=debug" http://company.com/launch.jnlp and the runtime giv...

Java to batch file

Can any body help me in knowing how to pass a parameter from a Java program to a Batch file which is also used in the same java program. The following stub indicates the piece of code where I run the batch file Runtime rt = Runtime.getRuntime(); rt.exec("C:/test.bat"); I need to know if I could pass some parameters to test.bat which ...

How to clean session attribute from all active session in java ?

Currently I am working on web project which uses JSP/Servlet and struts framework. We are using cache mechanism. I want to clean some of the session attribute from all the active sessions on particular event (For e.g. in case of refreshing cache). So what is best way to implement same ? ...

JAVA NIO ByteBuffer allocatation to fit largest dataset?

I'm working on an online game and I've hit a little snag while working on the server side of things. When using nonblocking sockets in Java, what is the best course of action to handle complete packet data sets that cannot be processed until all the data is available? For example, sending a large 2D tiled map over a socket. I can think...

Tomcat 6 file upload strategy

Hi Gurus, I have been using tomcat for sometime and still can't find a good way to do file upload. Just wonder how you guys handle file upload. You know how you can create a symlink in the application to another fs. but then by default tomcat removes your symlink and everything within the symlink. so this add extra steps to auto deploy...

How do I Invoke 3 REST endpoints in parallel ?

I have to invoke REST endpoints A, B & C in parallel and combine the resulting JSON from each into one JSON. All REST endpoints reside on different servers. My initial design calls for 3 Callables executed via FutureTasks. I will then do a Future.get(1000ms) on each FutureTask until they return a value. Is this how you would solve this ...

digital clock

any builtin classes available to display the digital clock in java?? ...

How to create "clone" of controller in Grails ?

Hi, I have a menu that loaded from main layout. in the menu I have to highlight the specific menu if users click on that menu. I detect it based on Controller name. I have 2 menu that has different names ie Users Edit and Client Edit. Both actually share the same controller (ie: UserController) and same Domain. I tried to create ali...

text editor

what are the methods available to implement text editor in java?? ...