java

How is import done in Java?

For instance import org.apache.nutch.plugin.Extension, though used many times, I've no much idea what is done essentially. EDIT: Is org.apache.nutch.plugin essentially 4 directories or fewer than 4 like a directory named org.apache? ...

JApplet Not Stopping or Reacting to Keyboard Input

Hi, I've been messing around with awt/swing lately trying to learn how to do applets. I have written the following short JApplet example code, which on the surface seems to work. The problems I have occur when I try to exit it: Pressing ESC does nothing, in fact line 38 is never reached when I run it in the debugger (nor is line 94 -...

efficient algorithm to compare similarity between sets of numbers?

Hello, I have a large number of sets of numbers. Each set contains 10 numbers and I need to remove all sets that have 5 or more number (unordered) matches with any other set. For example: set 1: {12,14,222,998,1,89,43,22,7654,23} set 2: {44,23,64,76,987,3,2345,443,431,88} set 3: {998,22,7654,345,112,32,89,9842,31,23} Given the 3 set...

Is there any COM library for Java that works well?

I'm rewriting a script that uses COM to automate a windows application, and I'd like to rewrite it in Java. The thing is, the COM libraries seem a little outdated, and I don't want to waste time with code that doesn't work. Is there anything you tried and worked? ...

Passing a concrete List of EnumMap objects to generic List of EnumMap parameter causes compile error

I have a piece of code that I think should compile, but it doesn't. Here is the code: public class Program { public void myMethod(List<EnumMap<? extends MyInterface, String>> map) { } public void caller() { EnumMap<MyEnum, String> map = new EnumMap<MyEnum, String>(MyEnum.class); List<EnumMap<MyEnum, String>> list = new LinkedList<E...

Clojure While Loop

I trying clojure i am trying to figure out how to implement the following algorithm, I am reading from an input stream i want to continue reading until it is not a delimiter character. i can do this in java with a while loop but i can't seem to figure out how to do it in clojure? while read readChar != delimiter do some pr...

A java practice problem

I came across this problem in javabat(http://www.javabat.com/prob/p183562): We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than...

Finding the window at a point on screen in java

Is there any cross-platform way to figure out which window is at a certain point on the screen? If there is not, what would be the equivalent function to getWindowAtPoint for linux (X11?) and OS X? ...

How comes .array() doesn't work on ByteBuffers returned from map'ed FileChannels?

I'm doing memory-mapped IO in Java. The FileChannel class allows you to map a ByteBuffer to a particular part of a file. I'm doing that with a file opened read only. The problem I am having is that I'm getting an exception when I attempt to call the .array() method on the resulting ByteBuffer. Perhaps that's because the .array() return...

.NET to Java Tutorials

I have been asked to create a simple database web app using Java. I'm a C# .net programmer and I haven't really created any Java web apps before. Do you guys know of any good books/online tutorials that can help me catch up on how Java web apps work? I got very little time to get up to speed, so any thorough examples will help a lot. ...

How can I make Japanese characters appear correctly in a JTextField?

Hi I have copied http://ja.wikipedia.org/wiki/メインページ url and pasted that url into a JTextField but it shows some squares( [][]...[].) instead of those chars "メインページ". How can I solve this problem so that the url is shown correctly? Like this, see when I copy url (of any language) into this message box it is showing as it is, not as sq...

Looking for feedback on a use of the Adapter pattern.

In a project at work we have a certain value type class in our domain model that includes a very large number of attributes... public class BigValueType { private Foo foo; private Bar bar; private Baz baz; //... } We've realized that we would like to "focus" this into a number of different, somewhat more specialized c...

What does it take to become a Java expert?

I was just reading this thread and wondered if it's easier to become a Java expert than a C++ one? Is it because it's very easy to write wrong code in C++ while in Java you have less flexibility (memory management for example) which prevents you from writing code horrors? Or is it because C++ is just inherently harder to learn and master...

Java open-source project to contribute

I want to contribute as a developer to an open source java project. Most of the projects in apache/java.net are not in development or are very difficult to be a commiter.Can anyone please suggest me project which are relatively easier to get into as a developer with 2 years java experience. ...

how to read my blob column from mysql to string type in hibernate

how to read my blob column from mysql to string type in hibernate I have try this way but alway return me: [B@196f4b5 Article article2=f.daoArticle.findById(article.getSrcUrl()); String vbody = article2.getArticle(); System.out.println(vbody); \\hbm <class catalog="ariso" name="countaword.ariso.dao.Article" table="a...

JBOSS MDB - What is the use of Configuration Property Annotation: maxMessages

Possible Duplicate: Configuring an MDB in JBOSS Hi, What is the use of maxMessages property and how this will affect performance. Thanks, Rod ...

How do I communicate with HTTPS? (Basic Stuff)

I'm not too familiar with networking in JAVA but what i'm basically trying to do is create a couple of threads that will "talk" to each other using HTTPS for security reasons. I'm not sure about the terminology so what I'm looking for is a pointing in the right direction. Hopefully, this should be pretty easy for experienced JAVA networ...

Presenting Data In A Tree Form

Hello Guys, I am stuck in my project for a while and decided to contact you guys for ideas because am short of ideas how to get it done. This is the task: I have information like this from the server and have to present the information in a tree form structure to the user. The data from the server comes in this form: APP net ...

How to find out which HTML button was pushed in my servlet?

I am creating a registration form which contains two submit buttons. I need to know which button is clicked in the form in my servlet code? ...

How can I cancel a long-running query using Spring and JDBCTemplate?

The JDBC java.sql.Statement class has a cancel() method. This can be called in another thread to cancel a currently running statement. How can I achieve this using Spring? I can't find a way to get a reference to a statement when running a query. Nor can I find a cancel-like method. Here's some sample code. Imagine this takes up to 10 ...