java

How to invoke Java methods through COM

I have a classic ASP/VBScript application that needs to call methods in a Java class. I discovered two products that apparently can do this: Java2COM and Java COM Bridge. Can you recommend one from experience, or is there yet another mechanism by which we can do this which is better? I'd rather avoid having to write C++ code if possible,...

Get the second level domain of an URL (java)

Hi All, I am wondering if there is a parser or library in java for extracting the second level domain (SLD) in an URL - or failing that an algo or regex for doing the same. For example: URI uri = new URI("http://www.mydomain.ltd.uk/blah/some/page.html"); String host = uri.getHost(); System.out.println(host); which prints: mydomain...

What is a good tool for Natural Language Detection in Java?

I need to do natural language detection (with confidence scores), preferably in Java, I'd really not introduce more platforms/technologies at this stage of the project. I have previously used the Google API for this in a PoC, but I now need to scale up to very large amounts of data, so any web-based solution won't cut it, (also Google ar...

What's the difference between how @Component and @Repository / @Service annotations are processed?

I've stumbled upon a rather strange issue today with Spring 3.0: There's an abstract class A and its concrete implementation A_Impl. A_Impl is annotated as @Repository and is auto-scanned by Spring (<context:component-scan> and <context:annotation-config/> are both declared in context). A and A_Impl are deployed in separate JARs (not su...

Warning : No pom file was found, assuming default settings!

Hi, I installed Maven 1, following the doc here http://maven.apache.org/maven-1.x/start/install.html Installation was successful, then I typed in "maven site" as shown in the doc here maven.apache.org/maven-1.x/start/quick-start.html I get the error "Warning : No pom file was found, assuming default settings!" From what I understand...

Is there an open source Java package that has classes representing HTMLElements?

I've noticed that the W3C publishes a set of Java interfaces around HTML elements, but I'm looking for implementations. Apache has HttpComponents, but those are for Http requests, whereas I need classes to wrap HTML elements. Anyone know of a package that will do this for me? ...

Problem creating a web service from a WSDL

The problem I'm having is that when I attempt to create a web service in netbeans using this wsdl, netbeans says that there is no service defined. I'm new to the whole wsdl thing but as far as I can tell there is one defined. The wsdl is: <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/...

Environment variable to control java.io.tmpdir?

I've used the TMP environment variable to control things like where gcc writes it's temporary files, but I can't seem to find an equivalent for java's createTempFile API. Does such an environment variable exist? ...

Get fresh data for a list of entities

We're using jpa with Toplink as an implementation and came up with a problem about refreshing lists of entities. Basically this is the scenario: private List<Entity> findAll() { final String sql = "SELECT e from " + anEntityClass.getSimpleName() + " e"; final Query query = itsManager.createQuery(sql); List<Entity> result = ...

How to determine by reflection if a Method returns 'void'

Hi, I have a java.lang.reflect.Method object and I would like to know if it's return type is void. I've checked the Javadocs and there is a getReturnType() method that returns a Class object. The thing is that they don't say what would be the return type if the method is void. Thanks! ...

General classes/source code for solving Java algorithmic problems?

I need to build a small repository of algorithms with implementation and description. I found recently, for example, an efficient permutations generator for permutations of arbitrary length. Where can I find full source code implementations with short descriptions of other such algorithms? Anything covered in the Java API is not needed,...

Walking a Linux/Unix filesystem with Java?

I need to create a Java util that will recurse its way through a Unix (and/or Linux) filesystem and build an object model of the directory structure, retrieve file info - size, created date, last accessed date etc - plus I need to retrieve info on the physical storage device the files are sitting on. Ideally, this util will be portable. ...

Why isn't Collections.binarySearch() working with this comparable?

I have this Player class which implements the Comparable interface. Then I have an ArrayList of Players. I'm trying to use binarySearch() on the list of Players to find one Player, but Java is giving me a "cannot find symbol: method binarySearch(java.util.ArrayList< Player>,Player)". This the Player class: class Player implements Compa...

Android Dropdown Effect - Spinner or not?

Achieving a true "dropdown" effect (as seen in Adobe's Photoshop Mobile app for Android, image below) has proven challenging using Androids built-in methods. As others on Stackoverflow have told me, editing the style of a dropdown list view of an Android spinner is limiting. How is this dropdown effect done? (I can't seem to get an ...

Speed issues with Google App Engine + Spring MVC + Annotations

Hello, I am developing an application on GAE with spring MVC and using annotations. The application take a long time to load the first time and then it behaves well as long as I access the application. But then when I leave the application for a minute and then I access it again it is taking long time. I have read ppl having similar is...

Equivalent Spring custom Collection property editor when using JSF

Hi, I would like to know how to use Converters in Java Server Faces similar to Spring collection property editor Suppose the following model public class Group { private String name; List<User> users = new ArrayList<User>(); // getter's and setter's } And equivalent form <form ...> <h1>Group form</h1> <label ...

My java server stops in the middle of its code.

For some reason my server stops running in the marked area of my code, and I can't figure out why. import java.net.*; import java.io.*; public class SlickServer{ public static void main(String[] args) throws IOException { int MAX_PLAYERS = 3; int playerNum = 0; Player[] players = new Player[MAX_PLAYERS]; ...

Easy way to store/restore encryption key for decrypting string in java

For encryption I use something like this: SecretKey aesKey = KeyGenerator.getInstance("AES").generateKey(); StringEncrypter aesEncrypt = new StringEncrypter(aesKey, aesKey.getAlgorithm()); String aesEncrypted= aesEncrypt.encrypt(StringContent); If I print out aesKey I get: "javax.crypto.spec.SecretKeySpec@1708d". So for encryption I ...

Can Derby / JavaDB _really_ encrypt with Triple DES rather than (plain) DES?

It seems to be confusing Triple-DES (>128bit) with plain DES (64bit). I'm trying to encrypt a Derby database with Triple DES (or DESede) using Java 1.5 I found this discussion forum message about a problem with JDK 1.5 by chance and so checked to make sure that it really was using DESede and not plain DES. When I created the database wi...

How to make the http connection timeout/disconnected after a time interval??

hi I am new in apache HttpClient, I used the following code to get the http connection timeout (disconnected) after certain time interval: PostMethod method = new PostMethod(authURL); HttpClient client = new HttpClient(); HttpClientParams params= new HttpClientParams(); params.setParameter(params.CONNECTION_MANAGER_TIMEOUT, 10); //10 N...