java

How do I import a java Point class in android?

Hi, I am writing an android game. I need a Point class that stores x and y coordinates. I have found a class called java.awt.Point. Which looks like what I need. I have created an interface for java.awt.Point and put import java.awt.Point in my code. But when I do Point pos = new Point. I get an error: cannot instantiate Point. A...

How do I view contents of blackberry cod file?

I there any way that I can see the contents of a Blackberry COD file to check which classes are in there? ...

hibernate createSQLQuery bulk insert

i try to execute these 3 statements, 1 and 2 success, but when reach 3 statement, i get error, is it because i trying to insert into same table during statement 2 and cause statement 3 fail? by the way, all 3 statement is inside one @spring transaction session.createSQLQuery(" select groupid from group_ where groupid = 888880005").exec...

Protocol Buffers Java RPC Stack

According to this Wikipedia entry: "Protocol Buffers is very similar to Facebook’s Thrift protocol, except it does not include a concrete RPC stack to use for defined services. Since Protocol Buffers was open sourced, a number of RPC stacks have emerged to fill this gap." However, there are no examples of RPC stacks cited. Can anyone ...

How to find if a Java String contains X or Y and contains Z

I'm pretty sure regular expressions are the way to go, but my head hurts whenever I try to work out the specific regular expression. What regular expression do I need to find if a Java String (contains the text "ERROR" or the text "WARNING") AND (contains the text "parsing"), where all matches are case-insensitive? EDIT: I've presented...

How to properly trim whitespaces from a string in Java?

The JDK's String.trim() method is pretty naive, and only removes ascii control characters. Apache Commons' StringUtils.strip() is slightly better, but uses the JDK's Character.isWhitespace(), which doesn't recognize non-breaking space as whitespace. So what would be the most complete, Unicode-compatible, safe and proper way to trim a s...

Monitoring memory consumption by different java objects

If we have 300 classes in an application, is it possible to monitor how many instances of each class we have at a given time? Is it possible to know how much memory each instance is consuming? Thanks ...

Fun with Java generics

Anybody knows how to write the piece of code below using generics AND avoiding compiler warnings ? (@SuppressWarnings("unchecked") is considered cheating). And, maybe, checking via generics that the type of "left" is the same as the type of "right" ? public void assertLessOrEqual(Comparable left, Comparable right) { if (left == nul...

JNI program hanging

In one of my Java projects I am expected to call a C function. As I am new to JNI, I first attempted a simple Helloworld program. I wrote a class with a reference to a native method by name sayHello() which returns void and takes no argument. I compiled the class and generated the header file using the javah utility. I then copied over ...

Java: Math condition

Hello, Is there a simple way to do this if (1 < x && x < 3) { .... } I want something like this: if (1 < x < 3) { .... } I know that the code above is wrong but.... Thanks ...

How to set DocFlavor for printservice in Java for WIndows.

Hello, I have written code to run the printer programatically in Java.I have to set the value of docflavor to print the .txt file.When I set it for INPUT_STREAM.TEXT_PLAIN_UTF_8 and run my program on Linux , it prints the text file.but when i run the same code for windows.It can't print the text file.It only prints the jpeg format...

Local variable assignment to avoid multiple casts

There was recently a question asking whether it was a good idea in Java to assign the results of calling a getter to a local variable to avoid multiple calls to the same accessor. I can't find the original post but the consensus seemed to be that this generally isn't necessary as Hotspot will optimise away the method call overhead anywa...

LOBs in BerkeleyDB

Hi, what's the usual way to store a CLOB (a few 100KB) inside Berkeley DB? ...

how to get the existing usernames from LAN in java

Hi everyone, I want to get all the usernames or IPaddresses from the LAN using java. Can anyone suggest me how to approach? Thank you. ...

Weird difference between new Date() and FileCreation date.

I'm running some test to prove a concept and i just wrote this code and found a weird situation: public class Test { public static void main(String[] args) { Date now = new Date(); File file = new File("/root/batch-experiments/test.txt"); try { file.createNewFile(); } catch (IOException e) { System.o...

How to create Roo Shell project in SpringSource Tool Suite?

Just have created a Spring project in STS and shown the view 'Roo Shell'. It's dialog has a link which opens a dialog 'Roo Shell Project Selection'. User is asked to select among a list of project one to work with the shell. Problem is that the list is empty. Is there a way to create a Roo Shell project or RooShellify an existing one? ...

How to get a Class Object from the Class Name in Java

I know the class name, say "MyClass" and want to retrieve the Class object, ie. MyClass.class for future references. Is there a way to do that? I've looked through the web but most of the things I found related to it were about the ClassLoader, which I presume are not suitable for my case. I do not want to initialize a class, but only g...

Date Format - Java

I want to accept a Date format according to an ISO (can't remember which one)... 2009-09-17T13:03:00 How do I do this? I'm currently using a SimpleDateFormat but when I run my unit test against it, it fails. DateFormat df = SimpleDateFormat("yyyy-MM-ddTHH:mm:ss"); Unit Test is passing it this string: String test1 = "2009-09-17T13:...

How to compare and remove objects from a Set<E> based on condition

I have a Set named scripts. The class E has elements like id,squence and many more . I want to compare two rows of object E in scripts and remove only if id and sequence are same . how do I do it .I have a code that removes all the rows . Can anyone correct this code to remove only the ones that has id and sequence same . Linked...

Pass Querystring parameter from SharePoint to Java Applet webpart

Hiya, I have a SharePoint webpart page, with a parameter in the page Querystring (in the URL), and I also have a Page Viewer webpart (which effectively IFRAME's the specified webpage), which shows a Java applet. Is there any way I can get the parameter in the SharePoint Querystring to be recieved by the Java Applet ? The reason for do...