java

How to show if a method may return null

After posting this question and reading that one I realized that it is very important to know if a method is supposed to return null, or if this is considered an error condition and an exceptions should be thrown. There also is a nice discussion when to return ‘null’ or throw exception . I'm writing a method and I already know if I want...

Management of Java string resources

I'm working on a java SE 1.5+ swing application, in conjunction with others. I'm wondering what the best way of managing string resources is. I understand the principles behind resource bundles etc. I'd like to avoid having one property file for every class that needs a string, as this seems a bit of overkill. Especially when you have a ...

Representing u1F000 as a Java string

I've got a bunch of unicode characters from U1F000 and upwards, and I'm wondering how to represent them in Java. A Java unicode escape is on the form "\uXXXX" and the Java language specification says that "Representing supplementary characters requires two consecutive Unicode escapes". How does that apply to U1F000? String mahjongTile =...

Introduction to Static Analysis

I'm a self taught programmer with almost non CS background. I'm currently learning about parsing techniques/algorithms/tools, and have a desire to build programs to analyze Java code. What kind of mathematical/theoretical CS do you have to know or take into account to build the most basic static analysis tools? A very simple thing that ...

JDialog not painting

I'm new to java but I would have thought this was pretty straight foward. I display a JDialog for user input when importing data from a text file but the dialog isn't being painted properly on other computers. On my computer if I run the program from within NetBeans or from the command prompt then the dialog displays properly. If I run ...

Override JComponent.getBaselineResizeBehavior() but keep Java5 compatibility

For my Swing project, I need to support both Java 5 and Java 6. I have defined a custom JComponent (call it Picture) and, after embedding it in a JScrollPane, I put it in a JPanel that uses DesignGridLayout manager. DesignGridLayout supports baseline alignment thanks to swing-layout open source library (implements baseline support for ...

Applet with Gui Designer

Hello, I want to ask you if there is a possibility to program a Java Applet in netbeans 6.5 using the GUI Designer. When I was adding a new file to the source and choose Applet or JApplet, I found now Designer as in a JForm for instance. With kind regards Sebastian ...

combine paths in java

Hi, Is there a java equivalent for System.IO.Path.Combine of C#? Or any code to accomplish this? ...

JUnit's @Ignore

I wonder if it is a good practice to use JUnit's @Ignore. And how people are using it? I came up with the following use case: Let's say I am developing a class and writing a JUnit test for it, which doesn't pass, because I'm not quite done with the class. Is it a good practice to mark it with @Ignore? I'm a little concerned that we m...

Java date formatting?

I want to read a date in the format YYYY-MM-DD. But if I enter date say for example 2008-1-1, I want to read it as 2008-01-01. Can anybody help me? Thanks in advance ...

create sql query in c++/java?

which method do you prefer for creating dynamic sql queries? formating or streaming? Is it just preference or there any reason one is better than other?Or any special library you use to it. EDIT: Please answer in case of c++. ...

Java Chart library for OLAP

Dear All, Is there any java chart library that supports OLAP data, like ChartFX Olap or Dundas Chart ? Thanks ...

id attribute of subview tag

I am learning jsf. I get class cast exception in java.lang.String when I use the following code: <f:facet name="header"> <f:subview id="header"> <tiles:insert attribute="header" flush="false"/> </f:subview> </f:facet> If I replace the subview id with another name other than header the code runs successfully. Eg <f:facet name=...

java: Rpc/encoded wsdls are not supported in JAXWS 2.0

Hello. I'm using CXF 2.1 to generate java code from a wsdl, but I'm getting the following error: WSDLToJava Error: Rpc/encoded wsdls are not supported in JAXWS 2.0 org.apache.cxf.tools.common.ToolException: Rpc/encoded wsdls are not supported in JAXWS 2.0 at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.c...

Viewing HTML inside Applet without using JEditorPane

Hello, I have a small (500kb) swing applet that displays very simple/limited set of small HTML page(s) inside it with JEditorPane, however this does not seem to work 100% fluently, some customers get a blank page displayed without any java exceptions. The page works OK from my machine. I need a more reliable way to show HTML page to al...

An alternative to Hibernate or TopLink?

Is there a viable alternative to Hibernate? Preferably something that doesn't base itself on JPA. Our problem is that we are building a complex (as in, many objects refer to each other) stateful RIA system. It seems as Hibernate is designed to be used mainly on one-off applications - JSF and the like. The problem is mainly that of lazy...

Is it possible to run JUnit tests from multiple packages in Eclipse?

Is it possible to run JUnit tests for multiple packages at the same time without manually creating test suites. For example if I have the hierarchy: code.branchone code.branchone.aaa code.branchone.bbb code.branchtwo code.branchtwo.aaa code.branchtwo.bbb Is it possible to: Run all tests in code.branchone and in descendent packages R...

Problem in addAppender() method in Log4j API

Hi I'm using log4j api for logging purpose. When I use the following code to append to the appender, it's showing "addAppender() is undefined for the type Logger" error FileAppender myAppender = new FileAppender(new PatternLayout(),"output.log"); Logger.getLogger(ConfigFileReader.class.getName()).addAppender(myAppender); Can anyone te...

Detecting Java Project Cruft

I'm a NetBeans 6.5 user and am searching for a way of generating a list of methods/classes that are not used within a set project group. I know I can right click on each method and select "Find Usages" but I'm looking for an automation to that process. I'm willing to look at something that runs outside of netbeans, as long as it genera...

What is the best Java OXM library?

Even though I've been a developer for awhile I've been lucky enough to have avoided doing much work with XML. So now I've got a project where I've got to interact with some web services, and would like to use some kind of Object-to-XML Mapping solution. The only one I'm aware of is JAXB. Is that the best to go with? Are there any other...