java

PHP's strtotime() in Java

strtotime() in PHP can do the following transformations: Inputs: strtotime(’2004-02-12T15:19:21+00:00′); strtotime(’Thu, 21 Dec 2000 16:01:07 +0200′); strtotime(’Monday, January 1st’); strtotime(’tomorrow’); strtotime(’-1 week 2 days 4 hours 2 seconds’); Outputs: 2004-02-12 07:02:21 2000-12-21 06:12:07 2009-01-01 12:01:00 2009-02-...

Making a JTable cell editable - but *not* by double clicking.

I am trying to add a column to a JTable with the following behaviour (similar to Windows Explorer and similar shells): The cell can be clicked once to select it, as usual. The cell can be double-clicked to perform a separate action (launching an external program.) The cell value (a string) can still be edited, by single-clicking a seco...

How to create an interface at Runtime

Assuming I have a class like public class FooImpl { public void bar(){}; } Is there a way to create its interface at runtime? e.g. public interface Foo { public void bar(); } I have been looking into Javasssist and the truth is it's reflection that I'm interested in using the interface for (as Esko Luontola and Yishai stat...

NetBeans and Eclipse-like "run configurations"

Is it possible to create anything similar to Eclipse's "run configurations" in NetBeans? I am working on a huge project which is currently not divided into any subprojects in Eclipse. There are in fact many applications in the project which have their own main-methods and separate classpaths. I know, it's a mess. I'm considering about ...

intercepting requests before they go to the controller in an annotation-based Spring web-app

Hello, I'm developping a web-app and i'm using Spring framework. Thing is, i never properly learned to use Spring and i'm kind of lost in all this. However, using Annotations-based controllers, i was able to create most of my app! Now, the problem is that i would need to be able ton intercept requests before they're sent to the contro...

Java - Collection with LinkedHashMap Attributes

Is there a collection class that has the LinkedHashMap quality of a predictable iteration order, but at the same time being indexable? LinkedHashMap implements a get() method, which returns the value object, but an indexof() method is not available. I'd like both. Thanks. ...

why is my unicode not working under passsenger??

This question contains java and ruby. I have a java program that I make a call to from ruby. This code works under merb perfectly without any modifications. This code will work under irb perfectly by setting $KCODE="UTF8". For the life of me I can not get it to work under phusion passenger -- this is a problem since our production ser...

How can I take a heap dump on Java 5 without garbage collecting first?

We have a long running server application running Java 5, and profiling it we can see the old generation growing slowly over time. It's correctly freed on a full GC, but I'd like to be able to look at the unreachable objects in Eclipse MAT using a heap dump. I've successfully obtained a heap dump using +XX:HeapDumpOnCtrlBreak, but the JV...

How programatically access a checkbox in .doc document in OpenOffice?

I have a strange question: in OpenOffice when opening a .doc file with checkboxes in it, I get a grey (meaning field) flat checkbox. It is different than the checkbox I can insert with the form components. I access this document with my program with the OOo UNO system, the problem is that this field doesn't appear in getTextFields so I ...

Lite version of a Java software

Our software currently has many features. I've been asked to make a free trial version which consist of a lightweight version of the full software. Only a few specific features would be available in the trial. And since a jar file isn't encrypted, I was relunctant to release a full version with hardcoded restrictions. I want to be able t...

Why is this generic method unsafe?

The following method generates a warning, but it looks safe to me. I'm sure the problem is with me: public <S extends CharSequence> S foo(S s) { return (S) new StringBuilder(s); } It looks like this will always return the argument s. Can anyone show an example that would cause this method to throw an exception? Edit: I'm not p...

Why is a ClassCastException only thrown when the return value is accessed?

Related to this question Given this function: public static <S extends CharSequence> S foo(S s) { return (S) new StringBuilder(s); } Why does this invocation execute without exception: foo("hello"); But this one throws ClassCastException? System.out.println(foo("hello")); ...

How do I get multiple hprof dumps in a Java WebStart (JNLP) application?

Working with a Java console application, I can do this: java -agentlib:hprof=heap=dump,format=b MyClass Then I can hit ctrl-\ (or ctrl-break on Windows) any time I would like to take a snapshot of the heap for later analysis. I would like to do the same thing for a Java Web Start application, but I cannot seem to get that to work. I...

Is it possible to persist data in GAE/java without using annotations?

I'm looking to add google-app-engine datastore persistence to one of my projects. So far, I've been reluctant to use the annotations, since I would want to have multiple DAO implementations ( e.g. Hibernate vs. GAE datastore ). Is there a way to have the persistence configuration done without annotations? I found no hints in the officia...

J2SE Proxy Authentication

We use 2 SIMILAR Microsoft ISA Proxy Server 2003 to connect to internet. Each Proxy has different Login style, as below : Server-1 : nt-domain\alan Server-2 : [email protected] Logon in IE, Firefox and my Phonecell via Wifi all are fine. But, a problem appears when we run a java application J2SE Ver 4, 5 and 6, where it needs internet a...

Auto-Starting Selenium RC on Windows XP

Greetings, I have completed developing a suite of tests using Selenium RC and Java and I'm trying to integrate them with the build system so I can run the tests overnight. The process runs like this: Cruisecontrol does a full build A cron job on the Cruisecontrol server installs the build on a specific test cluster. When the build in...

Create new class from a Variable in Java

Is there a way to create a new class from a String variable in Java? String className = "Class1"; //pseudocode follows Object xyz = new className(param1, param2); Also, if possible does the resulting object have to be of type Object? There may be a better way, but I want to be able to retrieve values from an XML file, then create the...

Is there a cleaner way to initialise this generic array?

Yesterday I attempted to create an array of objects, belonging to a non-static inner class of a generic class. It seems that there is no nice way of doing so. First attempt: public class Wibble<T>{ public static void main(String...args){ new Wibble<String>(); } public Wibble(){ Bar...

SSH Java-library for Android?

I'm trying to create an app for Android that simply sends a command to an SSH server. No response needed, I just need to be able to send a command. I was wondering if there's any java library out there that I could use? No advanced stuff needed, just a pure connection to send the command. ...

Why is preprocessor usage less common in languages other than C/C++/ObjC ?

I've been a Java and VB.Net programmer for about 4 years and a C# programmer for about 6 months. I've also used a bunch of dynamic languages like Perl, Python, PHP, and JavaScript. I've never had a need for a preprocessor. My question is: why do you see such extensive use of preprocessors in C, C++, and Objective-C but rarely (or neve...