java

Addin a JLabel in a frame?

I have created a JFrame, and now I want to add a JLabel and textfields in it. Please tell me how to do that. I have used the following code but its not working. JFrame i_frame = new JFrame("Select Locations"); i_from = new JLabel("From"); i_frame.getContentPane().add(i_from); i_frame.add(Box.createRigidArea(new Dimension(2,0))); i_frame...

Creating Nullables types in java

I am trying to create a nullalble object in Java but no idea how to do this , in C# this would be done like this int? someTestInt; This allows me to check for for null , while in certain cases i can use a 0 value ,this isnt always possible since certain execution paths allow 0 values ...

Should a software Service be completely standalone or can/should it be part of a larger component?

Hi all, I am in the process of refactoring 4 disparate software components that pretty much do the same thing into a single service (not a web service - necessarily or even likely). 3 are written in C++ while the last and most important is written in Java. The rest of the system is written in Java and therefore I will not be refactoring...

Eliminating the new line when using BufferedReader method to get user input using Java

In this first assignment I have to have the user input some number (ex: 312) then add each number and output something like: "The numbers are 3 1 2 with the sum of 6." Here are the codes: public static void main(String[] args) { int Max_Size = 30; char[] myArray = new char [Max_Size]; String temp = " "; char parse; i...

No images displayed when website called from self written webserver

I have Java webserver (no standard software ... self written). Everything seems to work fine, but when I try to call a page that contains pictures, those pictures are not displayed. Do I have to send images with the output stream to the client? Am I missing an extra step? As there is too much code to post it here, here is a little outli...

How to do source cleanup / code formatting (defined in eclipse) using ant task

Hi all We have a defined a set of rules in Eclipse for code formatting and clean up. is there a way to run the code clean up using ant task ? I know that there are tools like checkstyle but these tool have thier own configurations and rules, and I don't want to maintain 2 sets of rules. I'm looking for an ant task that will use the s...

Why is there no cancel button in Android's progress dialogs ?

I'm facing the same head-scratching moment similar to what this person (from Jan 2008) experienced when I realize that there is no cancel button in Android's progress dialog or spinners. It is now July 2009 and I've just installed the cupcake version of Android. Has this thing changed ? If not, are you adding a cancel button into the dia...

java & threads: interrupted exceptions & how to properly use BlockingQueue's take() method

Hi all, My first question is what exactly happens when there is nothing on the queue and a take() is called. The API says the method will wait but does that mean the CPU spins checking for empty/not empty until an item is on the queue or does it mean that the thread yields and will be awoken by an interrupt? If it is the case of the f...

Keeping state with remote EJBs and Web Services

I have a web-based application which makes use of remote EJBs for its business logic. Some of these EJBs are also exposed as Web Services. I need to keep a small state for some of these calls in order to allow subsequent calls to function correctly. Which of the following would you recommend? Stateful EJBs (will this work with Web Serv...

What can be done with 'PermGen out of space' exception in Tomcat-Spring-Hibernate web application?

We have an web application that uses Spring-Hibernate to persist registered users data in Oracle database. The application works fine in development environment, but when we copy it int live environment with much more data, it failed. Initially the application starts normally, but after few actions 'PermGen out of space' exception occure...

Rebuild indices of Java array

Hi, I have a bidimensional Object array in Java. Some indices aren´t nor used, because thei were skipped during array fill. Array looks like: Array[0][0] Array[0][1] Array[0][2] Array[1][0] Array[1][1] Array[1][2] Array[3][0] Array[3][1] Array[3][2] The 2 is missing, how can i rebuild the indices to make the array "correct"? ...

How do I write an uploaded file to disk using the Oracle directory alias and BFILE objects?

I have a java webapp which needs to upload files via http and then store them on the server. The files need to be associated with specific records in an Oracle database, so there will be a table in the database storing the reference to the associated record, and a reference to the file, along with other descriptive data such as title etc...

why does Spring use XML for component wiring?

Hi all, I understand the IOC concept, which we can mix-and-match different classes using wiring. Every class can get away from hard code it's dependancy by delegating the wiring / relationship handling to base xml (context xml). Here is my question, why do we use xml? we can simply wire all the components by using java class. Instead o...

install J2ME on Nokia 1200

I want to ask wether it's possible to develop a J2ME application for Nokia 1200 phone and then install the application as well as J2ME/Java runtime because it seems that Nokia 1200 doesn't include J2ME/Java runtime : (http://www.mobile88.com/cellphone/Nokia/Nokia-1200/specification.asp) . ...

Lack of support base class in Junit4/Jmock2

We're finally migrating our unit test code base from JUnit 3 to JUnit 4. We also make heavy use of JMock 2. With JUnit 3, JMock provides a useful base class for your tests (MockObjectTestCase), which as well as itself being s subclass of Junit's TestCase, it handles various housekeeping duties regarding the mock framework. It makes lif...

i got the url value using request.getHeader("Referer"), How to get the parameter values?

I need to split out parameters given a URL string. I got the url value using request.getHeader("Referer") e.g.: string rr=request.getHeader("Referer"); <%= rr %> i got the url as http://www.sun.com/questions?uid=21&amp;value=gg Now I stored that url in as string how do I get the value parameter value as uid=21 and value=gg Please r...

Good tool for system design in Java/Eclipse?

Does anyone know of a good tool for laying out class diagrams and the like for eclipse? Preferably soemthing that will let me draw up the relationships between the classes/interfaces and will then generate stub code for me to fill in. I've just been handed a 288 page API doc and told to implement it in Java and I want to make sure I h...

datasource configuration in standalone app when using Hibernate

Hi, I am wondering, where do we store database config in standalone app.The client is connected to database directly (I know it's not a good idea, but I am not allowed to create a server or open new port for RMI) I certainly don't want user open up Hibernate config xml file and get all the details (database username & password etc). ...

How to solve "java.io.IOException: error=12, Cannot allocate memory" calling Runtime#exec()?

On my system I can't run a simple Java application that start a process. I don't know how to solve. Could you give me some hints how to solve? The program is: [root@newton sisma-acquirer]# cat prova.java import java.io.IOException; public class prova { public static void main(String[] args) throws IOException { Runtime.g...

Java: Unresolved compilation problem

What are the possible causes of a "java.lang.Error: Unresolved compilation problem"? Additional information: I have seen this after copying a set of updated JAR files from a build on top of the existing JARs and restarting the application. The JARs are built using a Maven build process. I would expect to see LinkageErrors or ClassNot...