java

Java: "Could not find the main class. Program will exit"

I'm trying to run SQuirreL SQL. I've downloaded it and installed it, but when I try to run it I get this error message: Java Virtual Machine Launcher. Could not find the main class. Program will exit. I get the gist of this, but I have not idea how to fix it. Any help? more info: I'm on Windows XP pro. I have java 1....

What are the pros and cons of Web Services and RMI in a Java-only environment?

When developing distributed applications, all written in Java by the same company, would you choose Web Services or RMI? What are the pros and cons in terms of performance, loose coupling, ease of use, ...? Would anyone choose WS? Can you build a service-oriented architecture with RMI? ...

How do I set the proxy to be used by the JVM

Many times, a Java app needs to connect to the Internet. The most common example happens when it is reading an XML file and needs to download its schema. I am behind a proxy server. How do I set my JVM to use the proxy ? ...

Unrooted Tests

When running all my tests in Eclipse (Eclipse 3.4 'Ganymede'), one test is listed under "Unrooted Tests". I'm using Junit 3.8 and this particular test extends TestCase. I do not see any difference between this test and the other tests. I don't remember seeing this occur in Eclipse 3.3 (Europa). Clarification: We haven't moved to JUnit ...

JDBC Database Connections in a Web App DAL

I am building a small website for fun/learning using a fairly standard Web/Service/Data Access layered design. For the Data Access Layer, what is the best way to handle creating Connection objects to call my SQL stored procedures and why? Bearing in mind I am writing a lot of the code by hand (I know I could be using Hibernate etc to do...

JMXQuery connection - authentication failed

Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my MBean, so far this is what I got. java -classpath jmxquery org.nagios.JMXQuery -U service:jmx:rmi:///jndi/rmi://localhost:8004/jmxrmi -O java.lang:type=Memory -A "NonHeapMemoryUsage" Here's what I get. JMX CRITICAL Authentication failed! Credentials required ...

Best StAX Implementation

My quick search reveals the reference implementation (http://stax.codehaus.org), the Woodstox implementation (http://woodstox.codehaus.org), and Sun's SJSXP implementation (https://sjsxp.dev.java.net/). Please comment on the relative merits of these, and fill me in on any other implementations I should consider. ...

Unit testing a JAX-RS Web Service?

I'm currently looking for ways to create automated tests for a JAX-RS (Java API for RESTful Web Services) based web service. I basically need a way to send it certain inputs and verify that I get the expected responses. I'd prefer to do this via JUnit, but I'm not sure how that can be achieved. What approach do you use to test your we...

A Java API to generate Java source files

I'm looking for a framework to generate Java source files. Something like the following API: X clazz = Something.createClass("package name", "class name"); clazz.addSuperInterface("interface name"); clazz.addMethod("method name", returnType, argumentTypes, ...); File targetDir = ...; clazz.generate(targetDir); Then, a java source fi...

eclipse netbeans intelliJ Idea - IDE choice

With Netbeans recent milestones being very aggresive, Have you moved from eclipse to netbeans? This is also to anyone who may be using Ruby? At work, we are currently use eclipse, but many of us run our pet-projects on netbeans? you think netbeans will overtake eclipse? ...

How to reduce javax.faces.ViewState in JSF

What is the best way to reduce the size of the viewstate hidden field in JSF? I have noticed that my view state is approximately 40k this goes down to the client and back to the server on every request and response espically coming to the server this is a significant slowdown for the user. My Environment JSF 1.2, MyFaces, Tomcat, Toma...

Dynamically added JTable not displaying

Java Newbie here. I have a JFrame that I added to my netbeans project, and I've added the following method to it, which creates a JTable. Problem is, for some reason when I call this method, the JTable isn't displayed. Any suggestions? public void showFromVectors(Vector colNames, Vector data) { jt = new javax.swing.JTable(data,...

Sleep a thread until an event is attended in another thread

I have two threads in an Android application, one is the view thread, and the other a worker thread. What i want to do is to sleep the worker thread until the view thread terminates the handling of the onDraw method. How i can do this? is there a wait for a signal or something? ...

How can I add a REGEX match to my J2ME project?

The question pretty much sums it up. Just want to run a regular expression match on a string in J2ME. ...

Java: What is the best way to filter a Collection?

I want to filter a java.util.Collection based on a predicate. ...

Is there a way to get jadclipse working with Eclipse 3.4?

I'm a big fan of the Jadclipse plugin and I'd really like to upgrade to Eclipse 3.4 but the plugin currently does not work. Are there any other programs out there that let you use jad to view source of code you navigate to from Eclipse? (Very useful when delving into ambiguous code in stack traces). ...

Is there an easy way to attach source in Eclipse?

I'm a big fan of the way Visual Studio will give you the comment documentation / parameter names when completing code that you have written and ALSO code that you are referencing (various libraries/assemblies). Is there an easy way to get inline javadoc/parameter names in Eclipse when doing code complete or hovering over methods? Via pl...

accessing constants in JSP (without scriptlet)

Hi, I have a class that defines the names of various session attributes, e.g. class Constants { public static final String ATTR_CURRENT_USER = "current.user"; } I would like to use these constants within a JSP to test for the presence of these attributes, something like: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/co...

Can the Java File method "canWrite()" support locking?

I have a Java application that monitors a folder for incoming XML files. When a new file is detected I need to test the file that it is not currently being updated and is closed. My thought is to use File.canWrite() to test this. Is there any issue with doing this? Is this a good way to test that a file has been completely written? ...

What's the nearest substitute for a function pointer in Java?

I have a method that's about 10 lines of code. I want to create more methods that do the exact same thing except for a calculation that's going to change one line of code. This is a perfect application for passing in a function pointer to replace that one line, but Java doesn't have function pointers. What's my best alternative? ...