java

Bittorrent Peer Wire Protocol implementing in Java

I have a couple of questions regarding the Bittorrent Peer Wire Protocol. I am trying to implement it in Java using this spec. In Peer Wire Protocol section it says that all integers are four byte big endian values. AFAIK java uses big endian. Does that mean say if i want to send a choke message choke:<len=0001><id=0> Do i just write ...

Why am I getting a Null Pointer Exception from this Java code?

I have a method ... where I can't find the error: public String getUsernameforID(int id) { String statment = "SELECT USERNAME FROM `BENUTZER` WHERE `ID` = ? ;"; String username = null; try { PreparedStatement ps = dbCommunicator.getStatment(statment); // HERE : NULL POINTER EXECTION ps.setInt(1, id); ...

How to parse html and css to understand the layout of the page (java)

Hello all i need to find away to parse html and css layout to be able to transform it to to property language that understand simple html with inline css on each html element how i approach to such task ? ...

easy transactions using spring jdbc ?

I am working on a java app that uses Spring IOC and JDBC Template classes. I have a DAO class that has 4 methods : m1() to m4(). m1 performs multiple inserts and updates on table t1, m2 on table t2, m3 on t3, etc. The dao methods are used as follows: while(true) { //process & generate data dao.m1(data1); dao.m2(data2); dao.m3(...

How can I terminate a running Maven build in NetBeans?

If I run a Maven build in NetBeans which starts a long-running Java process (for example a HTTP listener or a JMX agent), terminating the process seems to have no effect. So I have to restart NetBeans and terminate the processes manually. I am using NetBeans 6.5 and 6.7 RC 1 on Windows XP and Vista. ...

Can Scala survive without corporate backing?

I was wondering whether Scala will get the takeup it deserves without explicit corporate backing (I was thinking by Sun/Oracle but I suppose it could be someone else, such as Google). With Sun's recent decision not to include closures in JDK7, couldn't they put their weight behind Scala as the Java alternative for those wishing to have ...

What are GeneratedMethodAccessor1,2,etc and why might they not be found?

I'm getting stack traces like this: java.lang.NoClassDefFoundError: sun/reflect/GeneratedMethodAccessor1 at sun.reflect.GeneratedMethodAccessor1.<clinit>(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI...

how to manipulate list in java

Edit: My list is sorted as it is coming from a DB I have an ArrayList that has objects of class People. People has two properties: ssn and terminationReason. So my list looks like this ArrayList: ssn TerminatinoReason 123456789 Reason1 123456789 Reason2 123456789 Reason3 568956899 Reason2 000000001 R...

What are recommendable data modeling tools and techniques for a Flex / Java web app?

I'm looking for a comprehensive setup that you've successfully used already. I've already loads of hints as to what building bricks I might use, but I'm not sure how to put it all together. Tools that need to be bought are OK, too. Details: I'm developing a Flex front end client for a Java server application and I have a set of model c...

What java validation library should I use?

I'm kinda stuck on this decision. My project already uses Spring and Spring Blazeds integration but I don't think there will be any real web interface (HTML). I have limited experience with Spring MVC and the Spring validators which are OK, but I've read comments from people suggesting not to use Spring validators outside Spring MVC. Wha...

Stop/Interrupt threads blocked on wainting input from socket

As the title says I need a way to stop or interrupt a thread that is blocked wainting on an input from the socket. ...

What minimum .jars do I need for BlazeDS and Spring?

I've managed to create a small project in Eclipse using the Spring & BlazeDS integration. Everything is working fine, my AMF requests are coming through and all is well. I just want to know what the minimum required .jar's would be. At the moment I have a list of more than 35 jars required to make just a very basic application work. It...

what is the difference betwen timestamp in java and php?

Hello, I have a java file that write records to the DB and time stamps I have another php file that reads that records.. unfortunately After converting the time stamp to dates I got a wrong dates ?? what is the problem !!! ...

Do I have to worry about InterruptedExceptions if I don't interrupt anything myself?

I'm using java.util.concurrent.Semaphore in a hobby project. It's used in a connection pool class I'm writing. I can use it with little fuss, except for this method: public void acquire(int permits) throws InterruptedException which forces me to handle the InterruptedException. Now, I'm not sure what "interrupting" a Thread even me...

Standard action

Hi, I really don't understand why the following code in JSP is running fine, but as described in Head first book, it will show compile time error. <html><body> <jsp:useBean id="person" type="foo.Person" scope="request"> <jsp:setProperty name="person" property="name" value="Fred"/> </jsp:useBean> <jsp:getProperty name="person" prope...

Get Bytes from an int to avoid bit shifting fun - Java (Median Filtering)

Hi All, I'm trying to perform a Median filter on an image in Java but it's terribly slow. Firstly, if any of you know of a standalone implementation I could use it would be fantastic if you could let me know. I'm implementing on Android, trying to replicate a small part of the JAI. In my method I take each pixel, extract the R,G & B va...

SWT composite - redraw problem

I have a composite element, that initially has a Label. Now I call dispose on the it (the label) and create another label in the same container (composite elm), but I don't see the new text. It brings me to question how do I enable redraw on the composite, so that the new label (or any other component I might create) will render in place...

Throwing exception to client in GWT (Google Web Toolkit)

I'm using GWT (currenly working with google's eclipse plugin), and I'm trying to throw an exception from the server to the client. My exception is something like class LoginException extends Exception implements IsSerializable But I get (upon loading in hosted mode): [ERROR] Errors in '[...]/src/myPackage/client/services/Sess...

Unable to call generic method with wildcard

I have a class defined like so: public class Test { static <T> List<Class<T>> filter(List<Class<T>> input) { // code here } public static void main(String[] args) { List<Class<? extends Throwable>> list = new ArrayList<Class<? extends Throwable>>(); filter(list); } } The filter meth...

Avoid jvm crash logs

My java app keeps crashing the jvm every time its closed. I think the crashes are caused by a third party dll im using, so i cant fix them. The problem is that a hs_err _pid.log log file is created on every crash, filling the CWD. Can be jvm crash logging disabled? Is there a way to do that from inside the running java app? Thanks! ...