java

Google AppEngine: how often does a "runtime startup" occur

I'm planning on hosting a JRuby on Rails app on Google AppEngine/Java. I found a great blog post by Ola Bini on how to to this, but in the summary he says: Overall, JRuby on Rails works very well on the App Engine, except for some smaller details. The major ones are the startup cost and testing. As it happens, you can’t actua...

Equivallent of .NET's WebClient and HttpWebRequest in Java?

.NET has HttpWebRequest and WebClient for simulating a browser's requests. I'd google it, but I'm not sure what keyword to use. I want to write code that does does HTTP GETs and POSTs, along with cookies, in an applet or local jar and gives me back the response in a text string or some other parseable structure. ...

JSONQuery parser in Java

Hi everyone, does someone know a JSONQuery parser in Java? Thanks a lot in advance! -- Andreas ...

Java Code formatting using shell script

I know this is silly but I can't overcome my curiosity. Is it possible to write a shell script to format a piece of java code? For example, if a user writes in a code: public class Super{ public static void main(String[] args){ System.out.println("Hello world"); int a=0; if(a==100) { System.out.println("Hel...

Good tutorial on OC4J Java Web Services.

Hi I'm new at developing web services but I would like to know if anyone knows a good place to find an end-to-end tutorial on how to develop, deploy, and test a Java based Web-Service onto an OC4J environment. Thank you ...

LDAP requests hanging for 15 seconds

I have JBoss application server that is using LDAP for authentication. Lately we have noticed that there are a lot of slow requests (> 15 seconds). I did some threaddumps of the server and noticed that many threads where waiting on a lock: com.sun.jndi.ldap.LdapRequest@54ceac java.lang.Object.wait(Native Method) com.sun.jndi.ldap.Conne...

How do you interpret this bit of Javadoc?

In the documentation for isValid(int) from java.sql.Connection (an interface): http://java.sun.com/javase/6/docs/api/java/sql/Connection.html#isValid(int) it states that it will throw an "SQLException if the value supplied for timeout is less then 0". Should implementors read this as "SQLException if and only if the value supplied for...

GlazedLists AutoComplete Changing Selection Doesn't Work

I am using the GlazedLists (1.8) library in my project, and I have been having trouble getting autocomplete working properly on my combo boxes. I installed a KeyListener on comboBox.getEditor().getEditorComponent() to catch when a user hits enter, so that I can do something based on what item they select in the combo box. I installed it...

Unreliable Hibernate Objects

I've run into a situation where the Hibernate object passed back from the query is unreliable. Consider the following code: MyClass myClass = myDAO.get(id); myClass.getId(); //This works myClass.getName(); //This returns null sometimes, and works sometimes Here's my get Method: @SuppressWarnings("unchecked") public T get(ID id) { ...

javadoc for package-info.java only

I have a situation where I'd like to execute javadoc in a project that has no classes. It only has package-info.java for one package. When executing javadoc, the following error is given: An error has occurred in JavaDocs report generation:Exit code: 1 - javadoc: error - No public or protected classes found to document. Is there any w...

How do I keep Tomcat deployed files in a context from caching in a browser?

I am working on a Java/Struts application that uses Tomcat 6.0.10. It's a typical web application that allows users to edit some forms, and streams PDFs. Way back, we added: <security-constraint> <web-resource-collection> <web-resource-name>GeneralRequests</web-resource-name> <url-pattern>/WR1/*</url-pattern> </w...

Checked exceptions in java

Possible Duplicate: The case against checked exceptions EDIT: It appears I didn't phrase my question correctly, and I can understand the frustration. I'm looking for some information that explains where I should use checked exceptions and where I should not use it. Most of the information on this subject is one sided - love/ha...

How do I use regex to split a string into characters?

I need to learn RegEx but don't have time to figure this out right now. -- So I'm attempting exploit the community's capabilities. I have a string containing a list of acceptable 1-character comment variables. String comments = "#;"; And I want: String[] parsedComments = {"#", ";"}; What RegEx string will solve my problems? Strin...

replace string in parentheses using regex

I have gone through all related topics here on regex and can't find one that really works for my case. What I want to do is: HLN (Formerly Headline News) => HLN which means: I would replace everything inside the parentheses to be "" (including the parentheses). My difficulty is how to find the pattern "(.+?)", when I tried it, it al...

How to map a datasource for a java web service

I'm trying to figure out how to use datasources for my web service. I have the oracle-ds.xml deployed on my jboss 4.2.3 server, and the datasources are showing as bounded to JNDI names java:TestDS, java:WeatherDS, etc. I try doing an initialcontext.lookup but I can't find it. I tried referencing the resource in the web.xml but I get "...

Why is the clone() method protected in java.lang.Object?

What is the specific reason that clone() is defined as protected in java.lang.Object? ...

Android: Showing indeterminate progress bar in TabHost activity

I know that the following code should show and hide a tiny circular progress bar with the following code in Android: requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarIndeterminateVisibility(true); setProgressBarIndeterminateVisibility(false); The problem is that I am using a TabHost and I need to be able to d...

How to replace tokens in a string without StringTokenizer

Given a string like so: Hello {FIRST_NAME}, this is a personalized message for you. Where FIRST_NAME is an arbitrary token (a key in a map passed to the method), to write a routine which would turn that string into: Hello Jim, this is a personalized message for you. given a map with an entry FIRST_NAME -> Jim. It would seem that ...

What is the .Net equivalent of Java's Dynamic Proxies?

In java it's possible to dynamically implement an interface using a dynamic proxy, something like this: public static <T> T createProxy(InvocationHandler invocationHandler, Class<T> anInterface) { if (!anInterface.isInterface()) { throw new IllegalArgumentException("Supplied interface must be an interface!"); } retur...

jmeter - able to render PDF?

Is there an add-on or a config setting that will allow Jmeter to Render PDF output? I am testing a web tool that exports report data to various outputs (excel, pdf, csv, etc.) and would love to setup an assertion to verify all outputs return the same value. The hitch is that Jmeter can't render pdf. Any thoughts? ...