java

download large files from a remote server, how to test for correct file and delivery?

There are 2 servers that are geographically very far from each other. One server does file processing, then saves the processed file in a directory: c:\processed\ Files can be 100-1GB in size. The 2nd server is to download these files. What techniques can I use to check if the file correctly downloaded? Is a checksum all I need to ...

classpath problem

Hi, I'm trying to compile the Servlet class in Tomcat's webappps/Email/src/Mail folder, but I'm getting compile time errors: ./Email/src/Mail/Mail.java:7: package javax.mail does not exist import javax.servlet.http.*; ./Email/src/Mail/Mail.java:9:package javax.servlet does not exist import javax.servlet.*; ./Email/src/Mail/Mail.j...

A Groovy Web Console in a Java webapp?

I've been looking at Groovy a little lately, and I love the idea of the Groovy Web Console. I'm idly wondering whether there's a way to embed a simple web control to write and run scripts from in a web app I might put together myself. Is there a plugin-style solution to embed a control like this? Are there any resources or guidance ou...

Printing output of another program to a java text area

I am creating a GUI using Java. This GUI launches a program from the command line using the ProcessBuilder class. A little information on the process being launched: from the command line, it creates another window and prints information to said window. In my GUI window, I have a text area to where I would like to redirect said ou...

How to insert <br /> tags into a java String

I am trying to insert line break tags into some text and displaying it on a web page. The < and > signs are being translated into &lt; and &gt; and the tags are showing up as text on the web page. The text looks like this when I select it from the database (I've output it to SYSOUT): version 12.4 service timestamps debug datetime ser...

Error in simple Java application

Just playing around with java trying to learn it etc. Here is my code so far, using HtmlUnit. package hsspider; import com.gargoylesoftware.htmlunit.WebClient; /** * @author */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("...

how to click on a button through java?

I want to access forms on HTMl pages throught Java Programming Language without involving real browser in between. At present I am doing it through HTML UNIT but it takes a bit more time to load a page. When it comes to accessing millions of page, then this extra bit time matters most. Is there any other methods for doing this? ...

generics in Groovy

Hi, The following Groovy code prints "it works" def printIt(Class<? extends Exception> clazz) { println "it works" } printIt(String.class) even though the parameter doesn't satisfy the constraint Class<? extends Exception> My understanding is that this is because: Type erasure in Java generics means there's no run-time generic...

Why do you have to write throws exception in a class definition?

Coming from C#, I just don't get this 'throws exception' that is written after a class/method definition: public void Test() throws Exception Do you have to write this? What if you don't? If I call a method that has this symbol, do I have to catch it? ...

Best way to use a PostgreSQL database as a simple key value store.

I am being required to use a postgreSQL database and it will replace my current use of berkeleyDB. Although; I realize this is not an ideal situation, it is beyond my control. So the question is... If you were required to make postgreSQL into a key value store how would you go about doing this, while making it as efficient as possible?...

How to navigate to another page after calling click?

I am trying to get all the main links, then click on them and navigation to the page: WebClient client = new WebClient(); HtmlPage page = client.getPage(url); // Get all links with a href of www.example.com/pages/1_ List<HtmlAnchor> links = (List<HtmlAnchor>) page.getByXPath("//a[href='www.example.com/pages/1_*'"); ...

Socket not disconnecting when connectivity changes

My chat application connects to a server and information is sent/received by the user. When the connection changes, such as 3g->wifi, wifi->3g, losing a data connection, etc, the socket sometimes stays connected for ages before disconnecting. During this time, it's impossible to tell if the connection is still active, it seems as if mess...

Java architecture coding conventions.

I have been working at a few different companies now and every one has different rules about how to name classes and packages. They each have different package layouts and workflow between classes. Through these experiences I have picked up an understanding of how to layout out a project; however, I would like a more concrete definition ...

JBoss web service client host url configuration

I have a ejb3 using a web service and configure the host name of the web service in the ejb-jar.xml file (or @WebServiceRef(wsdlLocation = "http:://myserver/service.wsdl") ). Can I do the same configure outside of the ejb-jar.xml file, similar to how a DataSource is configured? ...

Does this xpath look correct?

page.getByXPath("//*[@href='http://www.example.com/index.do/abc/1_*'"); Do I need to escape any characters? I am trying to get all ahref links on the page that have the pattern of: http://www.example.com/index.do/abc/1_ so these should all be retrieved: http://www.example.com/index.do/abc/1_asdf-asdfasdf http://www.example.com/ind...

How to implement asynchronous processing with J2EE application.

I have an enterprise application with around 2k concurrent users every day. These users handle customer calls so application speed is of vital importance. When a user is wrapping up a call they commit all the information they captured. This commit can take anywhere from 10-45 seconds. I am looking into ways to take the delay away fr...

Is it possible to run Java applets in the Android WebKit Browser?

Is it possible to run Java applets in the Android WebKit Browser? If not does anyone know when java applets will be supported? ...

How do I get maven managed dependencies copied into war\web-inf\lib so I can run my GWT 2.0 app in debug mode within Eclipse?

I am updating an existing project from GWT 1.5.2 to GWT 2.0.0. We use maven 2 to manage our dependencies and do all of our development in Eclipse 3.5. Because we use maven to manage our dependencies, I do not have all of those jars in the war\web-inf\lib directory as GWT specifies. Instead, they are in the maven repository, just where...

Implementing the singleton pattern in Java

Can anyone provide an example of a singleton pattern and explain why they are necessary? ...

Serial Communication between Java RXTX and Arduino

I'm trying to communicate between my PC (Windows 7 using Netbeans and RXTX) with an Arduino Pro, using the serial port. The Arduino is actually connected to the PC using an FTDI cable. The code is based on the Java SimpleRead.Java found here. Currently the Arduino simply prints out a string when it starts up. My Java program should pr...