java

Alternative for volatiles with cheapest performance hit

I want to implement the usual cooperative mechanism for canceling a thread. However the java memory model was only fixed in JDK5 while I'm in a pre-JDK5 environment. I understand, this means that doing something like this, as espoused in SCIP, will not be correct. class Worker implements Runnable { private volatile boolean _canceled...

Java SOAP Server that can be deployed in Tomcat, JBoss, Geronimo, etc. etc. etc.

I'm hoping to create a Java SOAP server which I can deploy in Tomcat, or in JBoss, or in Geronimo, or in XYZ, etc. etc. etc. Bottom line, it should have the least dependencies possible. I'm trying to avoid libraries outside of what's included in a standard java distro because of licensing/packaging/reusability issues. Can any provide...

UnknownHostException while redirecting queries to google and getting results in JSon object

Loading classifier from D:\PROJECT\classifiers\NERDemo\classifiers\ner-eng-ie.crf-3-all2008.ser.gz ... done [2.0 sec]. Original Query was riot in India. Parsing Queries and expanding tokens from the Ontologies.. {locations=[India], events=[riot]} Search query is null Something went wrong... java.net.UnknownHostException: ajax.googleapis...

Help me convert my Lisp code to a C-based syntax

If you know LISP, could you please change this into C-based sytnax for me (ie. C/C++/C#/Java ..etc)? (let ((g (* 2 (or (gethash word good) 0))) (b (or (gethash word bad) 0))) (unless (< (+ g b) 5) (max .01 (min .99 (float (/ (min 1 (/ b nbad)) (+ (min 1 (/ g ngood)) ...

loading applet in the web browser's page

import java.applet.Applet; import java.awt.Color; public class sampleapp extends Applet { public void init() { this.setBackground(Color.BLACK); } } I am trying to load the above mentioned applet in mozilla browser. <applet code="sampleapp.class" width="100" height="100"></applet> After hosting that web page(i...

Are there any open source command line tools to refactor java code?

I use vim as my editor but I would like to get some of the same power of the IDE's for java when it comes to refactoring. Are there any commandline tools for refactoring java? I could probably hack something together using perl or vim scripting but if there is something already out there I'd rather use that. ...

Is there a way to increase virtual memory in an application started from NetBeans?

In my project I often encounter Java heap space errors, i.e., there isn't enough space to run the program any more. Is there any way I can increase virtual memory? I am not using the command-line. I am using Net Beans. ...

How can I implement my LayoutManager without instanceOf?

For a certain layout that I'm working on, I need to make my own LayoutManager. It will lay out different components depending on what type they are: Labels in one way, Separators in another way, and everything else in a third way. I can easily implement this and to determine the different positions for different types of components, i...

Why is Java's GUI platform named "Swing?"

Why is Java's GUI development platform named "Swing"? What does it mean? ...

Is it worth it to use FLEX + JAVA

My group is about to start doing a big web based project/application. The app. itself will not be used by many people and it is basically only for Intranet use for managers and application developers. Our boss wants our programmers to use the following tech. stack: FLEX -> Cairngorm -> BLAZEDS -> JAVA (EJB3 + POJO) -> ORACLE DB Some of t...

Brief Idea about servlets

Where can I get knowledge about servlets? ...

how the subString() function of string class works

Hi please see the following code. String s = "Monday"; if(s.subString(0,3).equals("Mon"){} String s2 = new String(s.subString(0,3)); String s3 = s.subString(0,3); I know that line 2 will still point to "Monday" and have a new String object with the offset and count set to 0,3. The line 4 will create a new String "Mon" in string poo...

SWT/JFace: remove widgets

Group group = new Group(parent, SWT.NONE); StyledText comment = new StyledText(group, SWT.BORDER_DASH); This creates a group with a text area inside. How can I later delete the text (remove it from the screen so that I can replace it with something else)? ...

fonts on org.eclipse.swt.widgets.Composite are messed up on Linux

I extend org.eclipse.swt.widgets.Composite and create many widgets on it, (labels, table, text etc). The problem I am facing is that the labels' text is getting truncated on linux while it appears fine on windows. When I change the linux's font to gothic the truncation is little less but still there. Is there way to homogenize the wind...

How do I fix a StackOverflowError on Struts DispatchAction?

Here's the situation: I practiced creating a mini blog application. I used Strut's EventDispatchAction to handle all post related methods like updating and listing posts. I have an update() method (http://mywebsite/post?update) that updates the database and then if it's successful it forwards to the same action class but I used a differ...

Get html file Java

Duplicate: How do you Programmatically Download a Webpage in Java? How to fetch html in Java I'm developping an application that consists on: the user inputs an URL of some website, and then the application have to analyze that URL. How can I have access to the HTML file, using Java? Does I need to use HttpRequest? How does t...

What is your experience with ARM Jazelle?

I'm evaluating between open source and closed source JVM for ARM. In particular, the closed source JVM can make use of Jazelle (java acceleration for newer ARMs). Do you have any experice with this technology? (And BTW, which OS do you use with it?) ...

Java array: direct access to component in array

Am I able to access an array component directly such as: String x = args[1] ? or do I have to use a loop and use args[i] ? ...

Java generics for policy as alternative to passing policy in constructor

I have some Java code similar to: public class Thing { private IPolicy policy; public Thing(IPolicy policy) { this.policy = policy; } public void doSomething() { this.policy.execute(); } } My question is: is it possible to do this with generics rather than passing the policy to the con...

What is an open source Java project I could contribute to?

I'm looking for an open source project written in Java with a relatively low barrier to entry, ie. not hugely complex, friendly, etc. My background is mostly in web apps so, that'd be the best place for me to start. Mostly, I'm just looking for some place I can do some stuff in free time and keep my chops polished. I plan on browsing ...