java

Security with Java Scripting (JRuby, Jython, Groovy, BeanShell, etc)

I'm looking to run some un-verified scripts (written in a yet-to-be-determined language, but needs to be Java-based, so JRuby, Groovy, Jython, BeanShell, etc are all candidates). I want these scripts to be able to do some things and restricted from doing other things. Normally, I'd just go use Java's SecurityManager and be done with it....

How to convert java.util.date to java.sql.date?

I am trying to use java.util.Date as input and then creating a query with it - so I need java.sql.Date. I was surprised to find that it couldn't do the conversion implicitly or explicitly - but I don't even know how I would do this, as the Java API is still fairly new to me. Any suggestions? It seems like this should be an easy feat...

Fastest XML parser for small, simple documents in Java

I have to objectify very simple and small XML documents (less than 1k, and it's almost SGML: no namespaces, plain UTF-8, you name it...), read from a stream, in Java. I am using JAXP to process the data from my stream into a Document object. I have tried Xerces, it's way too big and slow... I am using Dom4j, but I am still spending way ...

removing junit testing to build in ant

Not so much a programming question but I figured I'd ask anyway. How do I make it so ant doesn't require that all the junit tests pass before building? In netbeans I can build the project without it testing first. However, when I run ant, it makes sure all my junit tests pass first. I am running ant from the command line in my netbea...

JAVA- Function to determine whether a poker hand is a straight?

Hello, for a homework assignment I was given a Card class that has enumerated types for the Rank and Suit. I am required to compare two pokerhands (each hand is an ArrayList of 5 cards) and decide the winner. The isStraight() function is really bothering me, because I have to start over the count after the Ace. For example, QUEEN, KING...

How do I merge a CVS branch into HEAD using the Eclipse merge tools?

I'm currently working in a branch I created using the Team-->Branch. How do I use Team-->Merge to merge my changes to the branch back to head? ...

Hibernate vs JPA vs JDO - pros and cons of each?

I'm familiar with ORM as a concept, and I've even used nHibernate several years ago for a .NET project; however, I haven't kept up with the topic of ORM in Java and haven't had a chance to use any of these tools. But, now I may have the chance to begin to use some ORM tools for one of our applications, in an attempt to move away from a ...

How would you use a regular expression to ignore strings that contain a specific substring?

How would I go about using a negative lookbehind(or any other method) regular expression to ignore strings that contains a specific substring? I've read two previous stackoverflow questions: java-regexp-for-file-filtering regex-to-match-against-something-that-is-not-a-specific-substring They are nearly what I want... my problem is the ...

Error deploying an app to JBoss 5 that was working fine on JBoss 4.2

Im trying to deploy an application (.ear file) to JBoss 5, and I'm receiving the following error. The app deploys fine under 4.2.2. 15:31:33,172 ERROR [AbstractKernelController] Error installing to Real: name=vfszip:/C:/ASE/ext/jboss-5.0.0.GA/server/all/dep loy/UGC-WS.ear state=PreReal mode=Manual requiredState=Real org.jboss.deployers....

automatically calculating column width in JTable

What's the preferred way of this (based on header & contents width I believe)? TIA. ...

Is there ever a case for 'new' when using dependency injection?

Does dependency injection mean that you don't ever need the 'new' keyword? Or is it reasonable to directly create simple leaf classes such as collections? In the example below I inject the comparator, query and dao, but the SortedSet is directly instantiated: public Iterable<Employee> getRecentHires() { SortedSet<Employee> entries ...

Qt Jambi vs SWT for cross-platform GUI development

I'm currently involved in a project developing applications primarily for Linux (Fedora 10). However, it might be the case later on that we will have to port these applications to Mac OS X and Windows and we don't want to be caught out by choosing the wrong GUI toolkit.* For a variety of legacy reasons we are locked into using Java. We ...

Overriding line number in generated Java source

Is there any way to override the line numbers in Java (e.g., by using some kind of preprocessor directive)? I am "compiling" a high-level language, down to Java byte code using Janino. I need compiler errors to report the line from the original file, not the generated Java code. C# has the #line directive, and I've successfully exploi...

jSecurity JDBCRealm SQL setup

Hello all! I am trying to use jSecurity for an enterprise java app, but the documentation is...well...lacking. Has anyone out there in SO-land been able to get the JDBCRealm setup, and if so did you find a SQL setup script or did you just derive it on your own? Either way, can you provide the create SQL statements to make this work? ...

Java Library? - Simplex / Linear Programming / Optimization

I'm looking for an optimization library. My two requirements are that it does not use JNI and that it does not have license restrictions preventing it from being used on multiple computers commercially. The only one I've found that meets these requirements is Choco, but it is unusably buggy. ...

Injector.getInstance(..) returns a new instance for a singleton

My Module: bind( Translator.class ).to( TranslatorImpl.class ).in( Scopes.SINGLETON ); Now I expect to get the same instance everytime when I do Injector injector = ...; injector.getInstance( Translator.class ); But if I do injector.getInstance( TranslatorImpl.class ); I get a new instance everytime. Is this a bug or expected b...

What are some good sample applications using Spring and Hibernate?

I need a quick jump start for using Spring and Hibernate together and I was looking for some sample code to modify and extend. Bonus points for Struts2 and Spring Security integration. ...

How to run jar application from window service registry?

DUPE: http://stackoverflow.com/questions/68113/how-to-create-a-windows-service-from-java-app I have developed a Java jar application which processes input file and converts into csv file. Now my requirement is to run that jar application fom windows service. I have no idea of how to do that. How can I make a Java application into a Win...

How to add a inner mapping in a nested collection?

Given: Object nestKey; Object nestedKey; Object nestedValue; Map<T,Map<T,T>> nest; Map<T,T> nested; How is a mapping added to nested where: nest.containsKey(nestKey) == true; ? Or is there an existing library of collections that would be more effective? ...

How much code should one put in a constructors (Java)?

Hello, I was thinking how much code one should put in constructors in Java? I mean, very often you make helper methods, which you invoke in a constructor, but sometimes there are some longer initialisation things, for example for a program, which reads from a file, or user interfaces, or other programs, in which you don't initialise onl...