java

What is null in c#, java?

Like... is it 0 like in C++? Or is it some "special" object? Or maybe something totally different? -- EDIT -- I do know what it is, the question is rather - how it's done ...

Trying to get distinct results, saying string cannot be cast to blah.Model.Article

Trying to get all articles, with unique titles (distinct(title)), that have a body of "". List<Article> articles = (List<Article>) session.createQuery("select distinct a.title from Article a where body = :body") .setString("body", "") .list(); I am getting the error: main java.lang.ClassCastException: java.lang.String cannot be cast ...

Logic differences in C and Java

Compile and run this code in C #include <stdio.h> int main() { int a[] = {10, 20, 30, 40, 50}; int index = 2; int i; a[index++] = index = index + 2; for(i = 0; i <= 4; i++) printf("%d\n", a[i]); } Output : 10 20 4 40 50 Now for the same logic in Java class Check { public static void main(String[] ar) { int ...

Async data fetching from Java WebService

Hello I'm implementing a client-server GPS application. Client side is a J2ME midlet that sends GPS location via HTTP/XML to a Java Webservice (Tomcat servlet). The servlet stores positions in SQL database. The other client app is a web browser that can login and see the actual position of midlet using Google Maps. This client is writte...

How to export my QtJambi project to .JAR file within Eclipse?

Hi, i am using Eclipse and i have a QtJambi project which i would like to export in a .JAR file. I have tryed several times it never worked. It worked for me on a Swing project, but with a QtJambi project, I dont know how to do it. Here are the screenshots (maybe it can help you to understand my situation): Export wizard (page 1) ...

Confused as to when you would use JMS (or a queue in general) versus a database

When you store a message in a queue, isn't it more of meta data information so whoever pulls from the queue knows how to process the data? the actual information in the queue doesn't always hold all the information. Say you have an app like Twitter, whenever someone posts a message, you would still need to store the actual message text...

Java framework for distributed system

I am looking for a library (or a combination of libraries) to build a java distributed system, made of several applications exchanging data through several pairwise connections (no mapreduce). For the moment I did an expolration of existing libraries and I could only discard what I'v found. Here are my requirements: Easy discovery of s...

Junit tests do not terminate when using Galileo eclipse on Ubuntu

Hi I'm using Galileo Eclipse on Ubuntu running inside a VirtualBox VM hosted on Windows XP. Eclipse is running under JDK 1.5 ( via the -vm command line switch ) The project that I am working with runs under JDK 1.3 ( set via the Build Path ) When I run a unit test from within eclipse ( by right clicking the source file and doing "Run...

How to insert ' in DB using Hibernate.

Hi all, I'm using hibernate for all DB operations. My problem is that, I want to insert an string in table which contains ' e.g. rea9'ea/rea9'ea. While inserting it I'm getting the following exception Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that c...

Java Sockets and Dropped Connections

What's the most appropriate way to detect if a socket has been dropped or not? Or whether a packet did actually get sent? I have a library for sending Apple Push Notifications to iPhones through the Apple gatways (available on GitHub). Clients need to open a socket and send a binary representation of each message; but unfortunately Ap...

HashMap: get arraylist to be a set of key or value

Hello people! I have two arraylists A1, A2. Each element of A1 would be the key and each element of A2 the corresponding value. So the solution that I found is looping on A1 ( A1 and A2 have the same size) making hashmap.add(A1[i],A2[i]) but is there a way to directly send the key value pairs as two sets? I want to avoid loops it is goin...

Boolean expression order of evaluation in Java?

Suppose I have the following expression String myString = getStringFromSomeExternalSource(); if (myString != null && myString.trim().length() != 0) { ... } Eclipse warns me that myString might be null in the second phrase of the boolean expression. However, I know some that some compilers will exit the boolean expression entirely if t...

java and matlab Integration

I need to import a plot graph from matlab into java swing GUI? Is there any way to do it? ...

Handling runtime exceptions in Java

HiAll, Can anyone explain how to handle the runtime exceptions in Java? Thanks, Ravi ...

Web-based Java IDE

Are there any good web-based Java IDEs out there? I would like to keep the environment as standard as possible to avoid IDE installation problems on each developers computer. Related: Is there any online IDE for Java? ...

How to get a distinct result, but return another column in the select?

I want to get a distinct result based on a property, but return the id in the select because I will be using it in a subquery. e.g. (List<Article>) session.createQuery("from Article a where a.id in (select distinct a2.title from article a2 where a2.body = :body"); setString("body", "") .list(); The key section is the subquery, I want...

BIRT 2.5 deployed with Xerces jar in WEB-INF/lib throws NullPointerException

Hi, so I am having pretty much exactly the same problem as what someone else has described here: birt-exchange. I have integrated BIRT with my existing web application that requires the xerces jar (mine is version 2.5) and the following exception is thrown when I attempt to view the report: java.lang.NullPointerException at org.ecl...

Controlling hibernate logging

I got an application running in a jboss container using hibernate. However I'm having trouble with the logging that hibernate is doing. I get these startup messages when Hibernate initialises: 2010-01-08 17:23:42,017 INFO [Configuration:1403] - Configuration resource: /hibernate.cfg.xml 2010-01-08 17:23:42,070 INFO [Configuration:1541...

rich:datatable rowspan issue

Hi all, I need to create a rich:dataTable (or even extended) with the following features: I have a class Company having a collection of Product objects. I want to show the following table: I still have not figured out how to do this with a subtable (in all the examples I found the subTable has the exact same columns as the master ta...

Maven 2 Not Running Junit 4 Tests

Hello, I'm having an issue getting surefire to run Junit4 tests. This same issue was reported in http://stackoverflow.com/questions/2021771?sort=newest#sort-top but the solution there was to removed the offending dependency whose transitive dependency caused the inclusion of junit3. In my case the dependency is necessary. I'm trying to f...