java

Java -- Exception must be thrown, but how?

I am getting an error in NetBeans saying I must throw an SQLException in this method: private void displayCustomerInfo(java.awt.event.ActionEvent evt) { int custID = Integer.parseInt(customerID.getText()); String info = getCustomerInfo(custID); re...

Initialize final variable before constructor in Java

Is there a solution to use a final variable in a Java constructor? The problem, if I init. a final var. like: private final String name = "a name"; then I cannot use it in the constructor, while java first runs the constructor an then the fields... Is there a solution to get in contact with the final var. in the constructor? ...

How can we open multiple IE instances while testing web appl. with selenium RC and java in eclipse?

I am running a test in Selenium RC with Java in Eclipse to browse two URLs. I get two Selenium windows, but testing of both URLs is done by opening one single IE window. How can I make it open the URLs on two different IE browsers and if possible, simultaneously? ...

Exposing a function to other processes

I'm using this piece of code that exposes a simple function using a socket: while (true) { try { ServerSocket serverSocket = new ServerSocket(7070); Socket clientSocket = serverSocket.accept(); String input = (new BufferedReader(new InputStreamReader(clientSocket.getInputStream()))).readLine(); synchronized (this.map)...

Preloading java classes/libraries at jar startup?

I've written a Thrift server in Java to take advantage of a specific Java package/library, but I'm not a java programmer. The problem is; I'm seeing a time-out for the first RPC call to the server. Subsequest requests are executed without any issues, and its only affecting clients written in certain (but essential) languages. My curre...

Java Webservice and .NET client dropping DateTime objects

Seeing something strange between a Java web service and the .NET client talking to it. We are sending an object back and forth with a DateTime property on it. Sort of like this (generated from the WSDL): [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.Debugg...

External javascript character encoding on Webshpere

Hello. How can one set character encoding on external JavaScript files using only Websphere (5.1)? I don't have Apache in front of it so I can't set it using "AddCharset UTF-8 .js". Or maybe there is some other way to force it on a web container via web.xml or similar magic? ...

What's the best way to implement a Java-like ByteBuffer in Obj-C?

I'm trying to build a application for the iPhone, although I am completely new to Obj-C. For one problem I'd use a ByteBuffer in Java, but I don't see any appropriate class in Apple's documentation. So I probably have to implement it on my own. My question is, how to do it best: Is there a similar class in Obj-C? (That would be the be...

Can't find ports with javax.comm api

I am trying to install the javax.comm api on a machine (I already installed on another machine and it is working fine) but when I run the sample "BlackBox" application I get a message that says "No serial ports found!". I have followed the instructions and put win32com.dll in the bin directory of the jdk, comm.jar in the lib directory o...

Problems porting Java to J#

I've got a medium sized (25k lines code, 25k lines tests) codebase in java, and would like to port it to run on a CLR as well as the JVM. Only the main class, and a few testing utilities deal with the file system or OS in any way. The rest of the code uses the generic collections APIs extensively, java.util.regex, java.net (but not URL...

How to handle translation of UI widgets in a massive project?

I am working on a large Java 1.4.2 project (~3000 files...) that contain lots of GUI widgets. There is a requirement to translate all text on the UI widgets to different languages (Italian, French, German), only European languages at this point. How would you go about designing a solution for such a problem? How would you verify that ...

Cannot Serialize/Deserialize ArrayList

I'm trying to serialize and deserialize an array list with a object inside: HairBirt param = new HairBirt(); param.setName("name"); param.setValue(2.3f); HairBirt param2 = new HairBirt(); param2.setName("name2"); param2.setValue(2.4f); ArrayList<HairBirt> list = new ArrayList<HairBirt>(); list.add(param); list.add(param2); ByteArra...

How do I make an http request using cookies on Android?

I'd like to make an http request to a remote server while properly handling cookies (eg. storing cookies sent by the server, and sending those cookies when I make subsequent requests). It'd be nice to preserve any and all cookies, but really the only one I care about is the session cookie. With java.net, it appears that the preferred w...

Best resources for a Java developer working on .NET solutions

My company has acquired several companies lately. We are a Java shop but have both VB .NET and C# .NET code bases now. I am about to start supporting these systems and am having trouble find good resources for finding the parallels/differences in .NET and Java. I have seen a few books but cannot decide which to buy, they all seem basical...

What is the difference between ? and Object in Java generics?

I'm using Eclipse to help me clean up some code to use Java generics properly. Most of the time it's doing an excellent job of inferring types, but there are some cases where the inferred type has to be as generic as possible: Object. But Eclipse seems to be giving me an option to choose between a type of Object and a type of '?'. So ...

Java API for XML

Hello, which is a good Java API for working with XML (both DOM and SAX approaches)? Is JAXP a good choice, or is it deprecated? And, what good tutorial on the suggested API do you know? Thanks. ...

In eclipse for java Is there anything like Visual Studio Custom Debugger Visualizers

The ability to create custom debug visualizers for any .Net type in Visual studio is an interesting feature. Is there anything similar in eclipse for java objects? ...

Annotation member which holds other annotations?

Hello! I want to create a custom annotation (using Java) which would accept other annotations as parameter, something like: public @interface ExclusiveOr { Annotation[] value(); } But this causes compiler error "invalid type for annotation member". Object[] also doesn't work. Is there a way to do what I want? ...

Gets byte array from a ByteBuffer in java

Is this the recommended way to get the bytes from the ByteBuffer ByteBuffer bb =.. byte[] b = new byte[bb.remaining()] bb.get(b, 0, b.length); ...

How to best execute a set of methods even if an exception happens

In a current Java project we have code similar to the following example: try { doSomeThing(anObject); } catch (SameException e) { // Do nothing or log, but don't abort current method. } try { doOtherThing(anObject); } catch (SameException e) { // Do nothing or log, but don't abort current method. } // ... some more cal...