java

how can we make an editable table?

what should I do for editing all the cells of a Table? for example if in a one cell is written "abc", I want to change it to" def", how can I do that? ...

Error calling Java web service from .NET code?

I'm getting an error in code that calls a Java web service. The code works fine on the rest of my team's PCs. I have exactly the same copy of the source code. So I'm guessing it's a configuration issue on my PC buried deep somewhere and has nothing to do with the source code itself? The error I get is: The HTTP request was forbidden...

iterator for loops with break

let say my code look like below for(..) for(..) for(..){ break; //this will break out from the most inner loop OR all 3 iterated loops? } ...

Run a batch file and then an exe file from Java program

I'm having two files that I've to invoke from a java program: a batch file that sets the environment. an exe file For running the exe, I need to have some environment variables to be set up, which am doing it with the batch file. set MSDEV_HOME=C:\Program Files\Microsoft Visual Studio 8\VC set FOO_ROOT=D:\UGS\Support_Dev\2005SR1 se...

Session Problem

The HttpSession session = request.getSession(true); and HttpSession session = request.getSession(); both creates a new session if there is none present. My problem is that i want to invalidate() the session if its allready present and then create a new one. I that possible ..i mean is there any way out to achieve this..?? ...

Custom JSP tag - detect existence of other instances

Is it possible for a custom JSP tag to detect if there are other instances of itself within a page? If so, what's the preferred way to do this? My tag's output needs to be conditional dependent upon whether it's the only instance or not. Note that my page has three occurences of my tag, two of which have a different set of attributes fr...

How to find empty catch blocks in Java code

Hi, is there any way to find out all the empty catch blocks inside Java code. I know there are some tools like PMD to do that, but i am using RSA, is there any way we can write a regex to search for empty catch blocks? Update: i am working on a corporate machine where i cant install new softwares :( ...

J2EE programmers do not write to files

Today one person told to me that "J2EE programmers do not write to files". Why can I not write to files from within a J2EE container (for example from JBoss)? What is wrong? ...

Editable JComboBox

if the user select the item which its index is 1,and change it from"123" to "abcd".how can I set "abcd" instead of "123" (in NetBeans)????Also how can I delete the item for ever???? ...

get string value from HashMap depending on key name

I have a HashMap with various keys and values, how can I get one value out? I have a key in the map called my_code, it should contain a string, how can I just get that without having to iterate through the map? So far I've got.. HashMap newMap = new HashMap(paramMap); String s = newMap.get("my_code").toString(); I'm expecting ...

Java Collection filtering

I have something like this: public class Foo { public String id; } and Vector<Foo> foos; I need to get an object from the collection by id. In C# I would do like this: foos.Where(o => o.id = 7) What's the best way to do that in Java ? ...

Where can I find source code for the Java data structures?

Hi all, Not sure if this has been asked before, did some digging. I'm trying to prepare for a few interviews, and I was just curious to see if how Java implements its data structures (arraylist, map), etc is public. Thanks. ...

Struts 2 data transfer and type conversions for primitive types.

Hi. I'm using java beans with automatic data transfer and type conversion. Ex: public class MyAction { public String execute(){ // .... } private double price; public getPrice(){ return price; } public setPrice(double price){ this.price=price; } } Let my request to be http://localhost:8080/my.action?price=21.3 Then in th...

Web service client close connection

I have a Glassfish app server hosting my web service (jax-rs with apache cxf). I have a Java client consuming this web service using code: Service service = JAXRSClientFactory.create("http://localhost/service", Service.class); The service is consumed x number of times at run time. x can vary. All is good - the code runs fine and as...

Object vs static method design

As shown below, there are two straightforward ways I could make a stream copier (bar introducing Apache Commons or similar). Which one should I go for, and why ? public class StreamCopier { private int bufferSize; public StreamCopier() { this(4096); } public StreamCopier(int bufferSize) { this.bufferSize = bufferSize; } public long...

Extract duration from a U-LAW audio file with Java

I'm trying to extract the duration from a audio file. This audio file is a U-LAW (G.711/MONO 8.000Hz). static AudioFormat ULAW_FORMAT = new AudioFormat(AudioFormat.Encoding.ULAW, 8000, 8, 1, 1, 8000, false); And all the time I'm receiving a exception: javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream ...

Parse user-input concerning search criteria

I'm looking for a way to parse some user-input. The input should show which searches have to be performed and how they have to be combined. 1 AND 2 (3 AND 2) OR 1 (3 AND 2) OR (1 AND 4) ( (3 OR 4) AND 1) OR 2 etc. The first example should combine the results of search 1 and 2 in an AND-fashion. The second example should combine the r...

Can I use throws in constructor?

I have to initialize file objects inside the constructor and for handling the exception, is it efficient using throws or should I go for try/catch? ...

What can I do to make jar / classes smaller?

I'm developing a Java Applet, and reducing the size of the binary code will make the applet open faster and will improve the user experience. Is there anything I can do to reduce the size of classes and / or jar files? I want to be sure I'm not missing obvious tricks. I know that in the C++ world compiler options for e.g. stripping deb...

rotating jlabel java swing

i'am using JTransformer class from swinghelper https://swinghelper.dev.java.net/ when i chose flowlayout there is no problem but if i use null layout i cant see my button on frame any help would be appreciated. import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.geom.AffineTransform; import java.util.ArrayList; imp...