java

getting the bottom 16 bits of a Java int as a signed 16-bit value

Hmmm. Consider this program, whose goal is to figure out the best way to get the bottom 16 bits of an integer, as a signed integer. public class SignExtend16 { public static int get16Bits(int x) { return (x & 0xffff) - ((x & 0x8000) << 1); } public static int get16Bits0(int x) { return (int)(short)(x); } public static...

Java IDE recommendations (GUI designer, ORM designer, etc...) for a VS user

Hi guys, I work with Visual Studio in my day to day job and I love the productivity features that it has. The Visual designers it provides are wonderful, such as for Winforms, WPF, DataSets, LINQ to SQL, Entity Framework, Class diagrams, etc... I am after a similar development experience for developing in Java. It has been many years...

Requirements for coding a Store Manager Application in Java ?

Hello Can anyone list the requirements for building a Store Manager Windows Application for an Online PHP Store. For e.g. here is an windows application which manages an online store: hXXp://www.pinnaclecart-manager.com/ I am familiar with Java and PHP. Can anyone list the requirements (i.e. any books, tutorials, libraries etc) to bu...

Sandcastle unified documentation generation for C# and Java projects

I have a set of related components that are basically provide the same functionality for various 'client' environments, like CLR and Java. Currently I'm generating my documentation using Sandcastle for the CLR components and I'm about to start the Java ones. I'd like to keep generating an unified documentation, with consistent look-and-f...

Hibernate not fetching public member

Consider the following code: @Entity @Table(name = "a") public class A implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="id") public int id; @Transient public B b; public B getB() { return B; } } When I fetch A, I'm manually filling B (another hib...

Good e-commerce platform for Java or .NET

I'm looking for an e-commerce "platform" in Java or .NET that can satisfy the following requirements: Product / Service Management Customer Account Management Shopping Cart Checkout / Merchant Integration Localization (especially for currency) Coupons Multiple Storefronts Reporting Possible PayPal / Google Checkout Integration The go...

How do you configure a DataSource in Java to connect to MS SQL Server?

I'm trying to follow Java's JDBC tutorials to write a Java program that can connect to SQL Server 2008. I'm getting lost at the point of making a connection. The following snippet is from the tutorial: InitialContext ic = new InitialContext(); DataSource ds = ic.lookup("java:comp/env/jdbc/myDB"); Connection con = ds.getConnection(); D...

GZIPInputStream reading line by line

Hello Folks, I have a file in .gz format. The java class for reading this file is GZIPInputStream. However, this class doesn't extend the BufferedReader class of java. As a result, I am not able to read the file line by line. I need something like this reader = new MyGZInputStream( some constructor of GZInputStream) reader.readLine...

Why doesn't Bloch's Builder Pattern work in C#

Consider a verbatim copy of Bloch's Builder pattern (with changes made for C#'s syntax): public class NutritionFacts { public int ServingSize { get; private set; } public int Servings { get; private set; } public int Calories { get; private set; } ... public class Builder { private int ServingSize { get; set; } priva...

Pattern for objects initialization at startup

I'm building an application and as time goes on, I have more and more objects to initialize at startup. Moveover, some of the newer objects depend on others so I'm getting some kind of spaggetti initialization where objects are created then passed to other constructors. I'm suspecting that I'm getting it wrong. For example I have a WinF...

Constructor injection with JBoss Seam

Hi, I'm new to JBoss Seam. I'd like to know how do I instantiate a class without a no-arg constructor in JBoss Seam. I have to instantiate JsonPrimitive (from Google Gson framework) that has just constructors which receive arguments. How the regular code would be: import com.google.gson.JsonPrimitive; ... JsonPrimitive jsonPrimitive =...

I don't understand why this ClassNotFoundException gets thrown

I'm executing the java binary from one of my classes, and a ClassNotFoundException gets thrown: Results of executing:/usr/bin/java -classpath "/home/geo" Geoline Error stream: Exception in thread "main" java.lang.NoClassDefFoundError: Geoline Caused by: java.lang.ClassNotFoundException: Geoline at java.net.URLClassLoader$1.run(...

How to get the Desktop path in java

I think this will work only on an English language Windows installation: System.getProperty("user.home") + "/Desktop"; How can I make this work for non English Windows? ...

Spring JPA Exception Translation

I have configured my application context as stated in the spring documentation to enable Exception Translation from jpa exceptions to spring DataAccessException. Should I also provide the implementation of PersistenceExceptionTranslator? If so, can anyone give me an example of how this is done? ...

Hibernate configuration

I'm trying to get started with Hibernate, and when executing my program I get an error during initialization. The exception is thrown by this class, copied from here: package net.always_data.bastien_leonard; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class HibernateUtil { private static fi...

Hibernate getting on my nerve. Delete question on One To One relationship.

Hi all, I have these classes. @Entity @Table(name ="a") class A{ private Integer aId; private B b; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id_a") public Integer getAId() { return aId; } @OneToOne(mappedBy = "a", cascade={CascadeType.ALL}) public B getB() { return b; } } @Entity @...

Git or Mercurial usage in Java projects

Just wondering if any of you are using Git or Mercurial for your Java projects, or is Subversion still the most popular choice? I've been looking at github.com and bitbucket.org lately, but because the repositories might be private, I can't get a good indication of actual usage. ...

Fastest way to iterate through large table using JDBC

I'm trying to create a java program to cleanup and merge rows in my table. The table is large, about 500k rows and my current solution is running very slowly. The first thing I want to do is simply get an in-memory array of objects representing all the rows of my table. Here is what I'm doing: pick an increment of say 1000 rows at a ti...

how can I lookup a Java enum from its string value?

I would like to lookup an enum from its string value (or possibly any other value). I've tried the following code but it doesn't allow static in initialisers. Is there a simple way? public enum Verbosity { BRIEF, NORMAL, FULL ; private static Map<String, Verbosity> stringMap = new HashMap<String, Verbosity>(); private Verbosity() ...

Compressing array of integers in java

I have some extremely large array of integers which i would like to compress. However the way to do it in java is to use something like this - int[] myIntArray; ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024); ObjectOutputStream objectOutputStream = new ObjectOutputStream(new DeflaterOutputStream(byteArrayO...