Archive for October, 2009

Oct 08 2009

Java primitive data type sizes for byte, short, int, long, float, double and char

Published by michael under Java

A handy list for Java data types and sizes

Integer Data Types

Data Type Size Digits Min Max
byte 8-bit signed 3 -128 127
short 16-bit signed 5 -32,768 32,767
int 32-bit signed 10 -2,147,483,648 2,147,483,647
long 64-bit signed 19 -9,223,372,036,854,775,808 9,223,372,036,854,775,807

Floating Point Data Types

Data Type Size
float single-precision 32-bit IEEE 754 floating point
double double-precision 64-bit IEEE 754 floating point

Boolean Data Types

Data Type Values
boolean true or false

Character Data Types

Data Type Min Max
char \u0000 or 0 \uffff or 65,535

Default Values

Data Type Default Value
byte 0
short 0
int 0
long 0L
float 0.0f
double 0.0d
char ‘\u0000′
boolean false
Any Object(s) null

References:
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

No responses yet

Oct 07 2009

How to find project dependencies in a Maven project

Published by michael under Java, Maven

cog-wheels
It’s very useful to be able to see what is included in your class path especially when you’re trying to track down a troublesome dependency. Recently I had an issue with a JDOM dependency; however I had not defined a JDOM dependency in my pom.xml file and I couldn’t quite figure out why this dependency existed. This is where Maven’s excellent dependency plugin comes to the rescue.

In a project you may have dependencies on libraries like Log4J or Freemarker. These libraries in their turn may have dependencies on other libraries, this is also known as transitive dependencies.

Using the following Maven command we’ll be able to see a list of these dependencies:

mvn dependency:resolve

For a nice tree view of the same information use:

mvn dependency:tree

If you want to see a full dependency trail that also show you artifacts that were rejected due to conflicts or other reasons then run maven with the debug flag enabled:

mvn install -X

For more information about the Maven dependency plugin go here: http://maven.apache.org/plugins/maven-dependency-plugin/

No responses yet