java

Why it doesn't draw an animated curve?

This is my class which I found on the Internet. It was originally an applet but I don't want to use it as an applet so I changed some methods (such as init() to a constructor). However, it doesn't work. Would you please help me? SignInFrame Frame: public class SignInFrame extends javax.swing.JFrame { Panel panel; /** Creates new fo...

EJB 3.1 @EJB Injection into POJO

Being a complete turbot this afternoon and cant seem to find the answer anywhere. With the new EJB 3.1 spec is it possible to inject an EJB into a pojo? I know in EJB 3.0 the @EJB annotation could be used to inject an EJB but this did not work on simple pojos. If it is not do I have to look the bean up in JNDI as I know you cannot sim...

Boxed Primitives and Equivalence

So I was asked this question today. Integer a = 3; Integer b = 2; Integer c = 5; Integer d = a + b; System.out.println(c == d); What will this program print out? It returns true. I answered it will always print out false because of how I understood auto (and auto un) boxing. I was under the impression that assigning Integer a = 3 wil...

Java web app security: adding tokens to requests

I'm looking for a method or current API that allows you to add on tokens to web app requests. Maybe within the session but not persisted. Or if you could help me by outlining an efficient method for doing this E.g. 1. GET request => Servlet generates a token and prints it in the view 2. returns a view with a hidden token <input typ...

Google App Engine, Java, and HTTP Performance

A friend and I are currently working on a turn-based game with chat with both desktop browser and Android clients, with Google App Engine as the server. We're using the Java API for GAE and using HTTP for communication with the server. We've implemented simple chat functionality, and we're getting undesirable latencies 1-3 seconds from...

JSON as an Encoding Protocol in a Large Distributed Application

I'm on a project that processes and reports on large sets of aggregatable row based data. There is a primary aggregation service and then many clients who can subscribe to different views of the data from that server. The objects are passed back and forth between the Java server and the C# clients encoded in JSON. We're noticing that the...

How can I create an animation frame with netbeans?

I use netbeans,and I insert an image on the lable which is on the desktop pane ,I want to rotate that image in its place ,what should i do? please help me. thanks. ...

Tool for creating Dynamically Generated Code in Java (In Eclipse)

In Visual Studio land, I used to be able to define a structure in an XSD file and add a special attribute to it which would cause it to be dynamically compiled and available to use with intellisense in the other C# files in the application. I am not sure exactly what the term for this is, perhaps "dynamic code generation." I am trying ...

OutOfMemoryError

I have one main class that contains 5 buttons each link to a program/package. Each package runs a jmf program that capture images from a webcam and it also loads about 15 images from file. The 1st program to load(regardless of which button i press) always runs correctly. But When i run a program after the 1st program ends, java.lang.Ou...

Memcached Provider for NHibernate not working

I've been at this for days. I have configure my web/app config to use the second level cache with a Memcached server and the provider from NHContrib. I don't get any exceptions yet in testing I see that it does not use the cache for my queries that I have set cacheable = true. If I switch the provider to the NHibernate.Cache.HashtableCac...

Inject into private, package or public field or provide a setter?

I see many Java examples using dependency injection with private fields without a public setter like this: public SomeClass { @Inject private SomeResource resource; } But that is a bad idea when the injection should be performed manually for example in unit tests. There are several possibilities to solve this: add a public sett...

Surefire is not picking up Junit 4 tests

For some reason I cannot get Maven 2 Surefire plugin to execute JUnit 4 test class. public class SimpleTest { @org.junit.Test public void simple() { System.out.println("foo"); } } However if I change this class to be JUnit-3 like, such as public class SimpleTest extends junit.framework.TestCase { public void testBar() {...

How to select from HQL

Hi im a newbe to HQL and have a SQL expression I need converted but am unable to select the SQL statement is: select SenseDate as Time,SenseValue as Value from UserData where NetworkID = '23' and IODeviceID = '129' and SenseDate >= DateAdd("d",-1, GETDATE()) and SenseDate<=GETDATE() and can run this part in HQL without problems: from...

Is it secure to upload an application on VPS Hosting Companies?

This is the first time I've to deploy an application on a VPS host somewhere around the globe. There are plenty of companies offering VPS services linode,slicehost... VPN looks to me like the most configurable/secure way of deploying my app (as I'm not a big Company with its own servers/upload bandwidth) My question is: Can we trust VPS...

Building a runnable jar with maven 2

I'm relatively new to the maven mantra, but I'm trying to build a command-line runnable jar with maven. I've setup my dependencies, but when I run mvn install and attempt to run the jar, two things happen. First, no main class is found, which is correctable. When I've corrected this, I get errors on run stating that classes cannot be fou...

How to execute web request in its own thread?

Hi, I am creating an android application which has to execute web requests in the background and then handle the received data and modify the user interface according to the server response. The goal of posting requests and handling data in the background is to avoid the freezing of user interface. Currently however I notice that the u...

Java object references with cache layer

We've created a caching layer to our J2EE-application. In this instance we use Ehcache. This has created a few challenges. Let's take this example. OrderItem orderitem = cache.getOrderItemByID("id"); OrderItem old_orderitem = cache.getOrderItemID("id"); orderitem.setStatus(1); old_orderitem.setStatus(2); If we're not carefull, any ...

Java workaround for BigInteger

I was working on a scenario wherein i had to implement BODMAS in Java and the operands could have as many as 1000 digits. So i chose to implement it in the following manner - I converted the infix expression (expression on which BODMAS was to be implemented) to postfix And then i evaluated the postfix expression by parsing every BigInt...

sun's application server?

in a tutorial they asked me to install the application server which could be downloaded from their site. what do they mean with application server? the link they provided: http://java.sun.com/javaee/downloads/index.jsp i mean come on sun, all these names. jdk then j2ee..and when i wanna download j2se it says jdk6. r they insane? a lot...

How can I use Facebook JAVA API in my application?

Hello Friends, I have downloaded facebook-java-api-3.0.2-bin from http://code.google.com/p/facebook-java-api/ for connecting to face book.I want to use this api in my java application to connect Facebook.I am developing a desktop application for this purpose.I have created account on Face book and registered as a developer. Is it pos...