java

Steps to debug/step through some java code?

Hi folks, yes, this is a very noobish question. I'm a .NET developer and I need to step through some java code to see exactly what is going on so i can port some java into some c#. So far i've not needed to do that .. until now. So .. i have absolutely zero knowledge of java debugging. So can someone please explain in blond-speak how i...

give delay for the batch file to run

Hi, I have asked this question before. I am having the folowing requiremet. Run the batch file. Give some time to run the batch file. 3.Close the batch file i have the following code that does not meet the requirement. Please tell me where i have made mistake Runtime rt = Runtime.getRuntime(); Process pr = rt.exe...

how to read and write from the serial port with java

I want write data to serial port then I'll get reply again I've to write data to the serialport. But the problem is, when I write at first time I'll get reply also but I couldn't write at second. my code package writeToPort; import java.awt.Toolkit; import java.io.*; import java.util.*; import javax.comm.*; import javax.swing.JOption...

is there a way class that extends httpservlet and thread

hi, i need answer for the question i have mentioned in the title. ...

Getting the size (in bytes) of the ResultSet using java code

How to get the size(in bytes) of the given ResultSet within the java code. Is there any direct way to find out? ...

Start timers in Java

Hi , I want a particular piece code to be executed after 5 minutes. How can I do that using Java? out.println("<HTML>"); out.println("<head>"); //out.println("<frame>"); out.println("<frameset rows=\"80%, *\" frameborder=\"0\" border=\"0\" framespacing=\"0\">"); out.println("<frame src=\"DataCenter...

Can I use JNDI to access FIles/their content?

Can JNDI be used in a Java servlet to access filesystem on the local machine or a remote machine? I am able to bind local directories/files with it, but not able to find a mechanism(if exists) to read/modify the file's contents. The files are simple text files. Please tell me if it is possible, and how? ...

Understanding for each loop in Java

The code below doesn't do what I expect. Every string is null after this code executes. String[] currentState = new String[answer.length()]; for(String x : currentState) { x = "_"; } The code below does what I expect. Every string in currentState is now "_" String[] currentState = new String[answer.length()]; for (int i = 0; i ...

fo:data-cell overflow

Hi, I am using XSLT -> FO to generate the PDF. When the text in a column exceeds the size of the column and there are no spaces in the text - then the text runs over into the next cell or outside the table. I want the text to be occupied within the same cell. Thanx in Advance, Swetha ...

Putting Spring integration tests in different classes and packages

I am using AbstractTransactionalSpringContextTests to run spring integrations tests. The spring context is loaded just once and then all the tests are run. How do I do the same if I want my tests to be in many classes and packages. Of course, the spring context should be loaded just once for all my tests (in all classes and packages), a...

How can I improve my junit tests

Right my junit tests look like a long story: I create 4 users I delete 1 user I try to login with the deleted user and make sure it fails I login with one of the 3 remaining user and verify I can login I send a message from one user to the other and verify that it appears in the outbox of the sender and in the inbox of the receiver. I...

What is best practice for serializing Java enums to XML?

Hi I have a Java enum and I want serialize a variable containing an enum value back and forth from XML for persistence. My enum is defined like this... public enum e_Type { e_Unknown, e_Categoric, e_Numeric } My variable is declared like this... private e_Type type; I want it to go into an XML tag like this... <type>value</typ...

command to close the batch file in java

Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(command); I am running the batch file by means of the above lines in java. The command prompt will be opened. I need to close the command prompt using java code Thanks ...

how to handle browser closing event in servlets

Hi i am having the html page in my web application. The page is locked by a client and unlocked by the same client. if the client forgets to unlock or close the browser, press back button on the page, and other links the page will locked always and cannot be unlocked. i need to unlock the page in the above cases if he forget to unlock T...

Java PMD warning on non-transient class member

On line: private boolean someFlag; I get the following PMD warning: Found non-transient, non-static member. Please mark as transient or provide accessors. Can someone please explain why this warning is there and what it means? (I understand how to fix it, I don't understand why it's there...) I'm getting this on many other memb...

Should I use Java date and time classes or go with a 3rd party library like Joda Time?

Hi, I'm creating a web based system which will be used in countries from all over the world. One type of data which must be stored is dates and times. What are the pros and cons of using the Java date and time classes compared to 3rd party libraries such as Joda time? I guess these third party libraries exist for a good reason, but I'v...

Does Java pass by reference?

Does Java really support passing by reference? If it doesn't, why do we have the == operator for finding two objects with the same reference? ...

how to write p%20roxy program in java

hi friends! In our workspace we have internet connection based on our IP address. they have gateway(p%20roxy) that accepts connection only from the specified range for eg., 15.8.18.1 to 151.8.18.20. i had an idea to route my packets from the my system to the some system that had IP in that specified range, that machine creates new pac...

How would you code an efficient Circular Buffer in Java or C#

I want a simple class that implements a fixed-size circular buffer. It should be efficient, easy on the eyes, generically typed. EDIT: It need not be MT-capable, for now. I can always add a lock later, it won't be high-concurrency in any case. Methods should be: .Add and I guess .List, where I retrieve all the entries. On second thou...

Determine remote client IP address for Java RMI call

When I implement an RMI server (implement an interface that extends java.rmi.Remote) is there a way to get information about the current RMI request context, specifically the remote client's IP address? public void myMethod() throws RemoteException { log.info("remote IP is "+ RMISomething.getSomething()); } ...