java

Which java web framework to learn?

I'm interested in a learning a java web development framework and I'm looking for some recommendations/suggestions on which one I should learn (and why). Ideally, I'd like the framework to: Be MVC based. Have minimal if any configuration Have an easy to use ORM Have decent session management Be easy to pickup I'm fam...

ANTLR ambiguous grammar??

I have couple of ANTLR rules that I don't know how to make them work The first rule is: STRING_LITERAL : '"' ( EscapeSequence | ~('\\'|'"') )* '"' ; The second rule is: element : name '=' math_formula ; math_formula : '"' expression '"'; The expression is a regular C like expression Example for the sy...

Generics: Type as variable?

hello In order to be able to substitute a specific implementation, it is commonly known to write List<AnyType> myList = new ArrayList<AnyType>(); instead of ArrayList<AnyType> myList = new ArrayList<AnyType>(); This is easy to understand, this way you might change the implementation from ArrayList to LinkedList or any other kind o...

Maven dependency versioning and java.lang.NoClassDefFoundError

Hi all, I have a Java project X has dependency (in pom file) on project Y. I was modifying in Y and build X,Y with Maven tool then runing X (on JBoss) without problems. When I added new class in Y then building with Maven (without problems), then running X, it throws java.lang.NoClassDefFoundError for the new class. I think its a Mav...

IntelliJ "Debug info unavailable" - how to fix?

I have a Java Tomcat web application built in IntelliJ that calls code in another module called "Stuff". I've attached the source of the relevant code to "Stuff" so I can step into it and hit breakpoints, but I cannot see variables or their values. Watches don't work either. All I get is "Debug info unavailable". How do I see the deb...

Sorting JTable programmatically

Is there a way to sort a JTable programmatically? I have my JTable's sort working (with setRowSorter) so that when the user presses any of the columns, the table gets sorted. I know, SWingX JXTable would probably work, but I'd rather not go through the hassle because everything else is pretty much working now and I don't know how wel...

main() in C, C++, Java, C#

Is main() (or Main()) in C, C++, Java or C#, a user-defined function or a built-in function? ...

Declaring 'long' over 'int' in Java

In Java, if int is enough for a field, and if I use long for some reason, would that cost me more memory? Does that vary on types? ...

In Java does anyone use short or byte?

Apart from using (byte[]) in streaming I don't really see byte and short used much. On the other hand I have seen long used where the actual value is |100| and byte would be more appropriate. Is this a consequence of the relative inexpensive nature of memory now or is this just minutia that developers needn't worry about? ...

add library to seam project

Hi, How can I add an library to a seam project? Do I need to copy them manually somewhere or edit the build.xml to do it for me? Or is there an automatic way provided by seam to add new libraries? BR, Cleber ...

WSMQ Queue Limit

Hi, is there a limit on how many queues I can have open within a single connection and single session? I can currently open up 128 queues and send messages to them. If I try to open up 129 I get the following error... Thanks Error: com.ibm.msg.client.jms.DetailedResourceAllocationException: JMSWMQ2008: Failed to open MQ queue 'TestQ...

Swing component and serialization

Why does Swing JComponent class implement the interface Serializable? The way I've implemented my views, they are stateless, all the state data is stored in a Presentation Model. So I don't need to serialize my views. I've used a @SuppressWarnings("serial") annotation to remove the warnings. Are there better ways to remove them? ...

Public/Private Key Encryption in Java and C, Windows and Linux

I'd like to implement a software licensing scheme. I like the looks of the TrueLicense package in Java, but it's overkill, and I need to validate a license file not just in Java, but in C on both Windows and Linux. Can anyone suggest an approach and/or libraries or tools to validate an encrypted file across Java and C, Linux and Wind...

Java: Unsigned numbers

Hello, Is there a way in Java to use Unsigned numbers like in (My)SQL? For example: I want to use an 8-bit variable (byte) with a range like: 0 -> 256; instead of -128 -> 127. ...

Seam auto login using credentials

Hi guys, I succesfully created a project using seam credentials for authentication, but right now some requirements has change (as usual) and i need authenticate the user automatic. See example bellow: user call the page: http://server%3Aport/project/index.jsp?parameter=xyz. This page has to call a seam component and get the parameter ...

What causes a Spring 1.2 NullPointerException when creating prepared statement?

Using Spring 1.2.1 and oracle.jdbc.pool.OracleDataSource 10.2.0.3.0 I sometimes get a stack trace like below. I think it is caused by the connection pool being full. Does anyone know the cause for sure? Also do newer versions of spring or Oracle JDBC handle this better? java.lang.NullPointerException at org.springframework.jdbc.c...

How does Hibernate find the generic type of a collection in a @OneToMany mapping?

Given a simple entity relationship: @Entity public class Single { @OneToMany public Set<Multiple> multiples; } How does Hibernate find out that the generic type of multiples is Multiple? This information is impossible to find with the standard Reflection API. I'm looking through the source code, but don't really know where to st...

Using getters() or using direct field access within a POJO?

Given a simple POJO does it really make a difference or are there possible side effects in using either one of the following: total = getPriorAmount() + getCurrentAmount(); OR total = this.priorAmount + this.currentAmount; When used within the POJO. ...

Crafting a Comparator object for sorting generic List<? extends T> using Collections.sort()

I am trying to implement a generic sort utility method for a List of objects of any class that implements MyInterface. Per Java API (http://java.sun.com/javase/6/docs/api/java/util/Collections.html), Collections.sort() method signature is: public static <T> void sort(List<T> list, Comparator<? super T> c) I am not sure if List with a ...

Reference to the iteration number in Java's foreach

How can you refer to the index of an array in the foreach? My code String[] name = { "hello", "world" }; for ( int k : name[k] ) { --- cut --- } I expecting that the foreach -loop will 1. set k = 0 in first iteration so that name[0] works correctly 2. set k = 1 in the next iteration... I get the error message foreach not a...