java

Best way to grab website content externally

There's a search site whose search results are generated dynamically by javascript. So the user enters a query, and the site displays the content on the page, without refreshing. I need to grab those search results programmatically (say from a Java program or a perl/python script). So ideally, I can launch my program with 100 queries...

Java Code Refactoring: Best beginner's books

Hi All, I am a java programmer. I recently have embarked on a refactoring project and so wanted to get some suggestions on any good books out there which can provide fast and practical insights for the same. I haven't done any refactoring projects before, and neither do I have much knowledge of design patterns yet, so some beginner leve...

Why do some languages need Boxing and Unboxing ?

Hi, This is not a question of what is boxing and unboxing, it is rather why do languages like Java and C# need that ? I am greatly familiar wtih C++, STL and Boost. In C++ I could write something like this very easily, std::vector<double> dummy; I have some experience with Java, but I was really surprised because I had to write som...

Why are generics completely disabled when you ignore a parameter type?

As a followup to this question, first the background Given a class with this declaration: public class SomeClass<T> And a subclass that does not use the generic parameter: public class SomeSubClass extends SomeClass A method on SomeClass declared as follows: protected Map<String, Object> getMap(Object param) { } If the subclass...

Jboss 4.2 swallows the stacktrace on causes of EJB Exceptions, how can that be prevented?

In JBoss 4.2.2 (on JDK5), I'm noticing this behavior. Is there a configuration or other way to prevent it? If I have code like this: try { doSomething(); } catch (Exception e) { throw new EJBException(e); } The resulting stack trace (when caught and logged) will be: EJBException .... at(..... at(..... caused by: NullPoint...

Strange Java error with annotations

Try to write: List<Object> list; @SuppressWarnings("unchecked") list = (List<Object>) new Object(); It will fail on the 3rd line, on the word list, with the following: list cannot be resolved to a type I understand that it is related to how annotations work. Anybody knows the reasoning behind this? EDIT: thanks for the fast answer....

Python "Event" equivalent in Java?

What's the closest thing in Java (perhaps an idiom) to threading.Event in Python? ...

.NET - vs EJB

What is the comparable technology of EJB (Enterprise Java Beans) in .net? ...

Java: Syntax and meaning behind "[B@1ef9157"? Binary/Address?

Hey, I'm trying to figure out what the [B@ prefix means in java. They come out when I attempt to print byte arrays. However, byte arrays of size 32 and size 4 are identical in length. Always "[@B1234567". What is this? Also, they have the property of only printing hex values. I know it can't just be a binary print because random ex...

How can I run unit tests for just the source files which have changed?

Is there a way I can get ant to run the unit tests just for the java classes it builds? For example, if MyClass.java is out of date, ant will build MyClass.class. After that I want it to also run MyClassTest and MyClassTestSuite if they exist. It doesn't have to be based on a naming convention. I'd be fine with using annotations or a...

Does Java not do things asynchronously?

I am trying to learn Java, I was reading a tutorial that said something like this: while (N <= 0) { TextIO.put("The starting point must be positive. Please try again: "); N = TextIO.getlnInt(); } It seems like when you ask the user for input it suspends until the response is recieved? I am used to these t...

Exception with ICEFaces

Hello, I'm using ICEFaces. I have datatable with multiple columns. One I load the page I get the following exception; however, the page still loads and contiues correctly but after I start pagination the table it's slow, I'm not sure what this exception is about as the page still work and I'm not sure if it's related to the slowness of ...

How to use command-line arguments to print ms office files?

hi all: We are doing an app to manage and print word, excel, power point and pdf files... No application can be shown to the user when printing to do that we find some command-line arguments that work well: (using openoffice.org) "C:\Program Files\OpenOffice.org 3\program\soffice.exe" -norestore -nofirsts tartwizard -nologo -headless...

How to design for JPA in a non-JEE web server (e.g. Tomcat)

Considering there is no @PersistenceContext available to inject the EntityManager, plus you need to manually manage Transactions, what is the best way to design such an application? For the EntityManagerFactory/EntityManager, as far as I can see, you must have each DAO accepting an EntityManager in the costructor e.g. public class DAOI...

Prevent system tray icon from stealing focus when clicked

I am writing an application in Java that places an icon in the system tray (via SWT). When this icon is clicked, I wish to have it automatically type some keys (via the Robot class) into whatever text field is in focus at the time of clicking (could be in any window). Unfortunately, clicking the system tray icon steals the focus away fro...

JNLP/Webstart - Setting environment variables

Is there a way via the jnlp file, to set up an environmental variable? I want to set the JAVA_TOOL_OPTIONS in order to do some LTW with aspectj. Thanks ...

Writing unit tests for network related classes

I have a class that is responsible for network communication. I would like to have a unit test for it. Here is where I'm stuck in order to write a test for it i have to implement a server to communicate with but that in turn will require its own test. How do you write tests for a class such as this? ...

Java Timer

I'm trying to use a timer to schedule a recurring event in an application. However, I want to be able to adjust the period at which the event fires in real time (according to the users input). For example: public class HelperTimer extends TimerTask { private Timer timer; //Default of 15 second between updates private int se...

Only one row editable on JTable

I am trying to make a special kind of jtable. I want the entire table to by default be NOT editable. But when the user clicks a row, then clicks the "Edit" jbutton, that specific row is editable. and once they deslect the row its no longer editable. How would I go about doing this? ...

Invalid parameter exception on client.auth_getSession() in Facebook java API

I want to connect to a my facebook application using the facebook java api 2.1.1(http://code.google.com/p/facebook-java-api/). My application is in "Desktop" mode so I should be able to access it outside of a web application. I have not defined any callback url for it as well. My code looks something like this. FacebookJsonRestClient cl...