java

How to display data from txt file in specific format

I have a text file input which contains data as below. How can I display data from the text file into specific format? Monday Jessy Walking 20 minutes Matthew Run 20 minutes Karen Jogging 40 minutes Jessica Run 12 minutes Tuesday Messia Walking 10 minutes Matthew Run 20 minutes Pete Run 10 minutes Carol Walking 30 minutes I want to dis...

EJB and FLEX

I'm working on a new application using EJB3 -> BlazeDS -> Flex. I can't find good example to see how to integrate EJB with BLAZEDS. Can someone give me some pointers on how to link them together. ...

Partial bean serialization and deserialization+merging

Hi! I am developing a RESTful web service. I have a bunch of entity classes (mostly JPA entities, but also other beans). There are gazillions of object mapping, serialization, binding and whatnot libraries out there. I'm looking for a one that will enable me to: Serialize the entities to XML and JSON Serialization MUST support usin...

Getting "unixtime" in Java

Date.getTime() returns milliseconds since Jan 1, 1970. Unixtime is seconds since Jan 1, 1970. I don't usually code in java, but I'm working on some bug fixes. I have: Date now = new Date(); Long longTime = new Long(now.getTime()/1000); return longTime.intValue(); Is there a better way to get unixtime in java? UPDATE Based on John...

Simple portlet jsp page flow question

I'm new to Java portlets, and am trying to get a handle on how these things work at a fairly basic level. I'm confused now about how to have multiple "views" in my portlet. Let's say my portlet will be used for CRUD operations. For the sake of simplicity, I'm imagining that when a user first views the portlet they'll see a table wit...

SWFUpload Examples/Information and Java

I built a couple working examples that upload an image to the server and display it on the page without refreshing. One approach was the iframe method, and the other was DWR (version 3). I wonder if anyone has an example using SWFUpload. I am not quite sure how it hooks into the server side code. Thanks! ...

Java Main Method, Good Coding Style

Hi there. I've had quite a long discussion with a friend of mine about the correct and good use of the main method in Java. Basically we have a class like this: public class AnImporter implements Runnable { // some methods, attributes, etc. } But where to put the main method? I concider it a good practice to "keep code where it belo...

cant see docs in javadoc

so i have this function: /** * @param parent ... * @param key ... * @param isRed ... * ... */ public redBlackNode(redBlackNode parent, int key, boolean isRed) { ... } and i cant see it or anything else that i documented in my javadoc... can someone please help. thanks! ...

Ideas for Summer Java project

Hi I'm taking an independent project during the summer at school. The prof. told me to come up with a good topic or a good project. He likes doing GUI in Java and I like the same too. So I was thinking a on doing a project in Java instead of doing research. He told me to present to him a good topic and explain what I am planning on do...

Regarding HotSpot optimization in Java

I've done some HotSpot optimization in Java. However, I'm now concerned about space in relation to loading classes (ie. only need one method in a class, don't want to load others). How would I go about doing so? ...

Running a JUnit test from Groovy Console

How can I use the Groovy Console to kick off junit tests? (Currently using Groovy 1.6.0) ...

How do you compare 2 items in a generic list?

I wrote a linked list implementation for my java class earlier this year. This is a generic class called LList. We now have to write out the merge sort algorithm for a lab. Instead of creating a new List implementation that takes Ints, I decided to just reuse the generic list I had created before. The problem is how do I compare two gen...

Can I use facelets in a google app engine app?

I would like to do some more learning of facelets. Now that java is a supported Google app engine language, is there anything in the facelets implementation that would prevent use on app engine? Edit: This page at google now has a list of various frameworks and their status in regards to app engine. http://groups.google.com/group/googl...

Please confirm that this XMPP code is not threadsafe

I'm reading the source code to the Smack api and the the method XMPPConnection#disconnect looks like this: public void disconnect(Presence unavailablePresence) { // If not connected, ignore this request. if (packetReader == null || packetWriter == null) { return; } shutdown(unavailablePresence); if (roster ...

Implementing a matrix, which is more efficient - using an Array of Arrays (2D) or a 1D array?

Hey everyone, When implementing a Matrix construct using arrays, which would be more efficient? Using a 1D array, or an array of arrays (2D)? I would think a 2D is more efficient as you already have the X and Y coordinates of an element, where in a 1D implementation you have to calculate the index. Any thoughts? Thank you Edit: it ...

uniqueidentifier in Sql Server database - how to generate in Java environment?

I have a database table that uses Sql Server 2005's uniqueidentifier column. I know how to create GUIDs in C#... string newid = System.Guid.NewGuid().ToString(); However, the application that is inserting into this database is running Java. Is there a way to generate Sql-Server-compatible GUIDs using Java code? (NOTE: generating th...

Struts2 Tiles - how to implement ?

I am just experimenting with struts2 tiles. I don't know how to implement it. Can anyone give any link for simple example of using strus2 tiles ? What is the basic requirement for that ? ...

Mini-OSGi that can run in a sandbox (like AppEngine or WebStart)?

I really like the concept of modular bundles as implemented by OSGi. I also like "managed deployment" services like Google AppEngine (for web application) or Java WebStart (for client software). These two ideas seem to complement each-other rather well conceptually. However, the OSGi standard includes a couple of features that make i...

Java (Swing) - Drag two windows at once.

How can I have one window move with another? i.e., I'd like a JDialog to follow a JFrame when the JFrame is being dragged. If the JFrame moves by (+5, +20), the JDialog needs to move the same. I've tried using ComponentListeners, but I only receive drag events in chunks which causes the JDialog window to be jumpy while dragging the ma...

Apache Cocoon JAR configuration - I want to use .class files !

Hey guys and gals I'm using the Apache Cocoon framework, set up several eons ago for the web app I'm developing. I don't know if its how cocoon is set up for everyone, or its if some 'special' configuration my company has performed, but this is what happens. In order for cocoon to use ANY class files, they must be bundled up into a JA...