java

Should I pursue Java or PHP for a career path in programming?

I've spent the last eight months working in the LAMP stack. Since I just graduated college with a degree in Computer Science, I'm still very new to programming. I've looked at the trends, and for non-Microsoft development stacks, Java and PHP top the list. Given that most of the Java positions in my area (Toronto, Canada) are for S...

JSF, multiple bean update property in a form

I edited my question to be more precise as I have more time to write it. I have a JSF form that should modify the value of the different properties of a dog : <h:form id="submit"> <h:outputLabel value="Dog name:"/> <h:inputText value="#{User.dog.name}" id="dogName"/> <h:outputLabel value="Name :"/> <h:inputSecret va...

Class method with class instace/object as arguments

hi, in Java is it valid to have the Class method with the argument as Class instance/object? Like: Class.method(obj)? ...

JComboBox "no text" text

I'm trying to reproduce the behavior of the search field of Firefox or Safari, or the search field of stackoverflow.com on the top right of this page. I mean, when there is no text on the editable JComboBox, an instruction text is displayed, like "Type here" or whatever. When the JComboBox is focused the text is removed. If the focus is...

Replacing all non-alphanumeric characters with empty strings

I tried using this but didn't work- return value.replaceAll("/[^A-Za-z0-9 ]/", ""); ...

Using Java Controls/Properties during runtime???

I cant seem to get this statement to work during run time. textWords.setText(item); textWords is an object, setText is a method and item is an integer. Anyone familiar with this? I cannot seem to get this to work during runtime. There is no error, during runtime it just doesn't do anything! public class frmMain extends javax.swing...

JList containing JCheckBox and a String, with non ctrl click selection?

Hi all, Been a while since I posted on here, and now I am at a point where I find myself stuck yet again. For my assignment at uni, we have been asked to create an address book application. It is going well, and it's nearly completed, however one part of the project, which is purely my preference, eludes me. I'm not asking for help on ...

Graph theory question, Java. Which algorithm to achieve the following.

I have a graph, with X nodes and Y edges. Weighted edges. The point is to start at one node, and stop at another. Now here comes the problem; Visualize the problem. The edges are roads, and the edge weights are the max weight limits for vehicles driving on the roads. We would like to drive the biggest truck possible from A to B. So the...

Ideas for implementing a VFS

Hi all, I have multimedia files and its metadata stored in a RDBMS (actually, the actual media files are stored in the FS, but let's not dwell on that). I would like to present a filesystem view of this information, so that users can work using Windows Explorer and similar stuff on the database. I intend this access to be read-only, wh...

Digital or LCD-like display class?

I remember seeing a tutorial on Sun's site that had a class for a digital-like display, but I can no longer find it. How would you make numbers appear like a digital clock, using Swing? ...

Junit import using * wildcard

I've noticed that when importing JUnit, the * wildcard doesn't always work. e.g. for the annotation @Test you must import org.junit.Test since org.junit.* doesn't recognize the annotation. Is there a reason for this, is it something that needs setting? or just a quirk in the way somethings like JUnit are. FYI, I am using: Junit 4.6, In...

The Best Way of Trimming Spaces in a String

How do I trim spaces inside leaving only one space taking consideration of performance? Input: AA BB Output: AA BB Input: A A Output: A A ...

A Bridge Pattern example

Hi all, I had spend some time on this Bridge pattern example from wikipedia, however, i still do not understand what is this bridge pattern trying to explain. interface DrawingAPI { public void drawCircle(double x, double y, double radius); } /** "ConcreteImplementor" 1/2 */ class DrawingAPI1 implements DrawingAPI { public voi...

Cross-site tomcat form post not working

Hi, For a customer, I need to write a Servlet which can print values in a form post. The form is hosted on another server and looks somewhat like this: <form action="http://myserver/myServlet" method="POST"> <input type="text" id="someName" value="someInterestingValue"/> <input type="submit" value="submit" /> </form> I have a Tomcat ...

How to parse (non well-formed) HTML in android ?

How to parse non well-formed HTML in android ? I tried to use XOM and TagSoup, but i get the following error when creating the Builder: 11-26 20:42:39.294: ERROR/dalvikvm(1298): Could not find method org.apache.xerces.impl.Version.getVersion, referenced from method nu.xom.Builder. Must i install Xerces to use XOM or can i use tagsoup ...

Using recursively returned reference to node in tree does not allow changes to the node itself

My data structures class is working with trees. We are implementing a 3-ary tree, containing 2 values with a reference to a left, middle, and right node (left subtree is less than value 1, middle subtree is between value 1 and value 2, right subtree is greater than value 2). An interface has been provided for the Tree class, and the fin...

Incremental deployment of java web applications

We have following problem. Developers frequently need to make small changes to our web applications. When I say small, I mean things like correcting the spelling on a web page or similar. Generating and redeploying war archives can be slow and costly in such scenarios. How could we automate and install changes incrementally? For example...

Need some help with XPath expression. One works, the other doesn't...

I'm using the COBRA HTMLParser but haven't had luck parsing one particular tag. Here's the source: <li id="eta" class="hentry"> <span class="body"> <span class="actions"> </span> <span class="content"> </span> <span class="meta entry">Content here </span> <span class="meta entry stub">Content here <span...

Can you determine if Vista UAC allows writing to a directory without elevation in java?

Here is the scenario. I have an application which writes a configuration file in its directory (user.dir). When the user cannot write to that directory due to UAC issues, I would like to change that to write to user.home/.appname/. The problem is that Windows really lies to my application and writes to user.dir which is in the Program Fi...

Weird problem getting input from getInputStream

Here's my code: Runtime re = Runtime.getRuntime(); BufferedReader output = null; try{ Process cmd = re.exec("java -jar myProg.jar " + myArgument); output = new BufferedReader(new InputStreamReader(cmd.getInputStream())); } catch (Exception e){ e.printStackTrace(); } String line; ...