java

need of Serializable interface in java? As there are no methods in the interface. and how does it maintain state of an object?

Hi classes which implement serializable interface what exactly they implement as there are no methods in the interface.And how does it help in maintaining state of object across a network. ...

Get hold of redirect url with Java org.apache.http.client.

Hi Experts! I need help with figuring out how to get hold of the redirect after I make a post to the server. First, I need to do a get to obtain some cookies from the server. Then I perform a post with the cookies and additional parameters. The server then answers with a 302 redirect. How do I get the url for that redirect? Code looks...

problems with RequestForFile() class that is using User class in Java

Okay I'll try to be direct. I am working on a file sharing application that is based on a common Client/Serer architecture. I also have HandleClient class but that is not particularly important here. What I wanna do is to allow users to search for a particular file that can be stored in shared folders of other users. For example, 3 us...

Encode params used within a post

Hello Experts! I need to encode the params to ISOLatin which i intend to post to the site. I'm using org.apache.http. libraries. My code looks like follows: HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("www.foobar.bar"); post.setHeader("Content-Type", "application/x-www-form-urlencoded"); HttpPa...

How to design an extensible type infrastructure with dependencies among each other

My application is an editor for connecting "modules" (through module ports). Ports have port types. Each port type has it's associated comparator. Two types are compatible if their attributes satisfy rules implemented in the comparator. I want users to extend the application by implementing new port types and rules how to connect them (...

How to execute random Javascript code on a web page?

Hello. I'm using htmlunit to test some pages and I'd like to know how can I execute some javascript code in the context of the current page. I'm aware that the docs say I'd better emulate the behavior of a user on a page, but it isn't working this way :( (I have a div which has an onclick property, I call its click method but nothing hap...

reading and writing from sockets

We're building an async thread per client server and stumbled upon a problem. We want the thread to always be ready to either read or write to\from the socket. We currently use the socket's reading method which is blocking and as a result we cannot issue any write requests. is there a way to interrupt the read operation? perhap...

the main class in a java source file?

im new to java. the standard code that is created after i created a new project in netbeans is: package helloworldapp; public class Main { public static void main(String[] args) { int[] array = new int[10]; array[9] = 1; System.out.println(array[9]); } } so you see that it uses the System class, but...

PSQLException: ERROR: relation "TABLE_NAME" does not exist

I am trying to run hibernate on a PostgreSQL 8.4.2 DB. Whenever I try to run a simple java code like: List<User> users = service.findAllUsers(); I get the following error: PSQLException: ERROR: relation "TABLE_NAME" does not exist Since I have option hibernate.show_sql option set to true, I can see that hibernate is trying to run ...

System.out.println() is a method to a field?

if out is a field to the System class. how is it that you can use println() method in a field? and where does this println() method come from, i cant find it in the System class. ...

Put external library to the JAR?

I have added some external libraries to my java project (in netbeans). Is it possible to put the external jar library to the java archive (and not to put them into a separate (for example) "lib" directory)? ...

Java: mytextarea.setText("hello") + Thread.sleep(1000) = strange result

I have something like this: for(int i=0; i<5; i++){ mytextarea.setText("hello " + i); try{ Thread.currentThread().sleep(1000); //to give time for users to read } catch(Exception e){} } I'm expecting it will display "hello 0" in the text area, wait for 1 second, then display "hello 1", then wait for 1 second, etc. ...

Where is java.nio.file

I'm new to java so I am not familiar with the framework yet. I am reading java documentation that tells me there should be a java.nio.file namespace. But when I attempt to import it the precompiler is complaining that it doesn't exist. What's up? ...

java implementation of Linked List Data Structure

Hello, I am trying to implement the linked list data structure using java, it works fine for insertion or removing first elements but fails to remove the last element via using the removeLast() method. My Linked List Node class: public class LLNode { String value; LLNode next; public LLNode(String value){ ...

class Main in a package?

Netbeans is creating a class Main automatically when I create a new project. so its in the constructor here i write the code and use all other classes? What happens when I rename the Main class to something else. Will it still work? ...

How can I interrupt a sequence of procedures in Java?

I have a bunch of procedures that need to be executed successively until either they are all executed, or a certain condition is met. Here's the basic code that needs to be executed until a condition is met: public boolean search() { robot.go(); robot.spin(); //etc - around 8 more similar commands (each takes around 2 seco...

How to Call Java Code from MySQL?

I found an article from 2008 discussing how to call Java code from MySQL. There were a lot of caveats and disclaimers because the process involved working with an experimental branch of MySQL. For a project I have in mind, it would be very useful to be be able to access Java libraries within MySQL, analogous to Oracle's Java Stored Proc...

Parsing Json Feeds with google Gson

I would like to know how to parse a json feed by items, eg. url / title / description for each item. I have had a look to the doc / api but, it didn't help me. This is what I got so far import com.google.gson.Gson; import com.google.gson.JsonObject; public class ImportSources extends Job { public void doJob() throws IOException { ...

How to start a Java project in Xcode?

I am currently programming Objective-C in the Xcode IDE, and I understand it should also support Java projects. When I open the IDE and choose New Project, I don't find any project templates that correspond to Java. I have Snow Leopard, so I assume my Xcode is up-to-date. How do I start a Java project in the Xcode IDE? ...

comparison of java and delphi

what is the comparison of programming language java and delphi? ...