java

Java class confusion

The word 'class' is used very loosely in Java tutorials and study material. There are many many different meanings to this word. Can some body please enumerate and explain all meanings of this word. E.g.: 'class' means an object, 'class' is an file extension, 'class' is the first word used in declaring object, etc. ...

Java Event Binding

Hello, I'm new in windows application development using java. The question is this "How to i bind events to custom class methods? As fas i have seen i can register listener classes to swing components to handle events. That is OK but i have to implement a class that implements e.g. the ActionListener interface to handle an event and t...

Calling a default servlet first in Java web application

Hi, I wand my SampleServlet to called first whenever my java web application is accessed in this manner : http://server:8080/appname/ Is there any way to implement this? Thanks, Veera. ...

Applets and JDBC

Hi Im new to Applets and I am trying to set up a login applet that connects to my mySQL database.... It shows in Netbeans but not when I load it.... Can someone have a look and give back any suggestions? P.S.Do I need to place my file in Tomcat? /* * To change this template, choose Tools | Templates * and open the template in the edi...

design of a Producer/Consumer app

I have a producer app that generates an index (stores it in some in-memory tree data structure). And a consumer app will use the index to search for partial matches. I don't want the consumer UI to have to block (e.g. via some progress bar) while the producer is indexing the data. Basically if the user wishes to use the partial index, i...

"cannot find symbol variable VK_NEXT"

My code says it can't find VK_NEXT. It can find all the other VK_ buttons just fine, but not this one. Is there another VK_ that let's me use the page down button? ...

Image comes up as just a grey square when added to JPanel

Hi I'm working on a project for university which is essentially a re-working of the Space Invaders game with the rules changed a bit. So far I've got a main JFrame, containing a subclass of JPanel (for the background image) which contains another subclass of JPanel which I'm using for the sprites. However, when I run it the JFrame and t...

How can I run a Maven webapp in Eclipse when I use profiles to populate properties files at build time?

Here is an example profile in my POM: <profiles> <profile> <id>QA</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <jdbc.url>jdbc:mysql://127.0.0.1:3306/SomeDB</jdbc.url> <jdbc.username>webapp</jdbc.username> <jdbc.password>somepassword</jdbc.password> </properties> </profi...

Impossible to use WSDL definition

A systematic breakdown of the problem follows. [Rewritten!] The client code using System; using System.Collections.Generic; using System.Linq; using System.Text; // This is a "sanitized" version of the real deal, of course. In reality I also require to // sign all incomming and outgoing messages and com. over SSL. The basic model is t...

Comitting binary files to SVN

svn doesnt commit a library like MySql connector, so when i commit my project it is not uploaded to the server, how can i do this, i how to sync another resources like pictures ...

Swing component flickering when updated a lot

Hi, I've got a couple thousand lines of code somewhere and I've noticed that my JTextPane flickers when I update it too much.. I wrote a simplified version here: import java.awt.*; import javax.swing.*; public class Test { static JFrame f; static JTextPane a; static final String NL = "\n"; public static void main(Strin...

What are real world examples of when Linked Lists should be used?

Another programmer was mentioning that they haven't found a use case for using a linked list data structure in any professional software in his career. I couldn't think of any good examples off the top of my head. He is mostly a C# and Java developer Can anyone give some examples where this was the correct data structure to solve a pa...

How can I return the generated keys to JDBC from a DB2 stored procedure that does an insert?

I've got a simple stored procedure that does an insert to a table with an identity primary key column. I need to get the key that was generated by the insert. I would prefer to use the standard JDBC getGeneratedKeys method but I'm not sure what the stored procedure needs to do/return to build that result set. My end goal is to do this ...

Refresh JPanel

I need to display different drawings on a JPanel. I have put the drawing files into an array, but when I changed it using a button, the JPanel only displays first drawing and doesn't change to the next drawing... I have called panel.revalidate(), but it doesnt work. This is the segment of the code that I used but not working. The JPan...

In Struts, where should the computations reside?

Hi, I'm strating out web programming in Java and I want to know the best practices. I'm wondering where should my computations reside in let's say a Java MVC app or a Struts apps? ...

In my application, why does readInt() always throw an EOFException?

(Forgive me because I do not write in Java very often.) I'm writing a client-side network application in Java and I'm having an interesting issue. Every call to readInt() throws an EOFException. The variable is of type DataInputStream (initialized as: DataInputStream din = new DataInputStream(new BufferedInputStream(sock.getInputStream(...

ORM: OneToOne mapping on Non Primary-Key Join column - Book and Inventory mapped by ISBN

I have a Book model and Inventory model mapped by ISBN number, but ISBN is not the primary key in either. Books belong to Bookstores and Inventory is for a group of Bookstores(BookstoreChain). Inventory is shared by all Bookstores belonging to a BookstoreChain. I'm using Hibernate @OneToOne mapping on the book side to fetch inventory i...

Common Java memory/reference leak patterns?

Maybe the most typical example is the JDBC closing done wrong way and not handling the possible exceptions correctly. I am very curious to see other examples you have seen - preferably web application related. So, are there any common leak patterns in Java? ...

How to organize packages (and prevent dependency cycles)?

I've been running some metrics on my Java project and apparently there are a lot of dependency cycles between packages. I didn't really know how to organize stuff into packages, so I just did what made sense to me, which is apparently wrong. My project is a neural network framework. Neural networks have Neurons, which are connected to e...

How to generate simple 2D graphics in real time?

For my internship on Brain-Computer Interfacing I need to generate some very fast flickering squares on a CRT monitor (flickering = alternating between two colors). The monitor's refresh rate is 85Hz and we would like this to be the bottleneck, which means that repainting all squares can take at most 1000/85 = 11ms. My language of prefe...