Hi,
I have a MyThread object which I instantiate when my app is loaded through the server, I mark it as a Daemon thread and then call start() on it. The thread is meant to sit and wait for information from a queue as long as the application is active.
My problem/question is this: Currently MyThread is extending Thread because I mark it a...
I have 2 different computers, each with different TimeZone.
In one computer im printing System.currentTimeMillis(), and then prints the following command in both computers:
System.out.println(new Date(123456)); --> 123456 stands for the number came in the currentTimeMillis in computer #1.
The second print (though typed hardcoded) resul...
... in an image and do some calculation on their [x y] coordinates.
My first idea was to use an image as the background of a JPanel and then register the points, but I'm not sure there will be a way to mark these on the JPanel. There is also the Drawing library, which I'm unfamiliar with, but I'm not sure if I can combine these with S...
import java.util.Scanner;
public class Fraction
{
private int numerator;
private int denominator;
private int product;
private int sum;
public Fraction(int num, int denom)
{
this.numerator=num;
this.denominator=denom;
if (this.denominator == 0){
System.out.println("can not divide by zero");
}// end if
}// end fraction
...
Can someone provide some simple code about how to use an encoded key in Java for the Google app engine. The sample code is a little bit confusing. Suppose I have an employee class and I want the primary key to be manually constructed with a format of "name, email, phone" for example a sample key would be"James Smith,[email protected]...
We have to lookup some data based on three input data fields. The lookup has to be fast. There are only about 20 possible lookup combinations. We've implemented this using a static HashMap instance where we create a key by concatinating the three data fields. Is there a better way to do this or is this the way to go? Code is below.
...
How do you weight the pros and cons between a Midlet and Browser based client/server app for a phone ...
What are the pros and cons of both...
And based on your experience what will you prefer to go in for and why?
I have listed some points based on which we can compare both feel free to add your own...
Rapid development.
Rich UI. ...
Whenever I update our project's code from the svn I have to set the build paths of the libraries I import again because the last person who made a commit has a different classpath from mine.
Is there a way in Eclipse to automatically put in the imported libraries after updating from the SVN? I have heard of build files (Ant,Maven) but...
The documentation of selectorObj.select() method states
This method performs a blocking
selection operation. It returns only
after at least one channel is
selected, this selector's wakeup
method is invoked, or the current
thread is interrupted, whichever comes
first.
I understand the documentation
The thread that is b...
On various mobile phone developer sites like Nokia, Sony Ericsson, Motorola etc...
I found Java ME development SDK's for mobile phones but only installable on Windows OS... I have a Ubuntu OS (Jaunty Jackelope) at home and was wondering if Mobile SDK's Linux installable versions are available?..
I have the NetBeans IDE installed on ...
In my Swing application, users enter styled text into a JTextPane which uses an RTFEditorKit (HTML is also a possibility).
I then need to render many of these styled notes at specific coordinates in a custom component.
I would think the View.paint method would be helpful here, but I'm not able to create a usable View object.
I have th...
I understand that the String class' hashCode() method is not guarantied to generate unique hash codes for distinct String-s. I see a lot of usage of putting String keys into HashMap-s (using the default String hashCode() method). A lot of this usage could result in significant application issues if a map put displaced a HashMap entry t...
In java, I want to log the exception being thrown from a piece of code:
try
{
doRiskyThing();
}
catch(Throwable t)
{
log.warn("too bad");
throw t;
}
The problem is that now my method must declare it throws throwable.
On the other hand, if I log the exception in a finally block, how do I know what exception is being thrown...
how do I configure autowire in spring
...
Is the output of Object.hashCode() required to be the same on all JVM implementations for the same Object?
For example if "test".hashCode() returns 1 on 1.4, could it potentially return 2 running on 1.6. Or what if the operating systems were different, or there was a different processor architecture between instances?
...
We are storing a String key in a HashMap that is a concatenation of three String fields and a boolean field. Problem is duplicate keys can be created if the delimiter appears in the field value.
So to get around this, based on advice in another post, I'm planning on creating a key class which will be used as the HashMap key:
class The...
I have a .txt file that has numbers 1-31 in it called numbers. I've set up a scanner like this:
cardCreator = new Scanner (new File ("numbers"));
After this, I'm kind of confused on which methods I could use.
I want to set up a conditional statement that will go through numbers, evaluate each line (or numbers 1-31), and includ...
I have a TreeMap that maps String keys to a custom City class. Here is how it is instantiated:
TreeMap<String, City> nameDictionary = new TreeMap<String, City>(new CityNameComparator());
CityNameComparator implementation:
public class CityNameComparator implements Comparator<String>
{
public int compare (String c1, String c2...
Hi.
I'm designing a little software in java.
Don't know the term/definition to what I'm doing, but I'm prompting commands from java to the terminal. Something like this:
Process process = Runtime.getRuntime().exec("command");
I've done this before in linux, and I used the gksudo for commands that required root password.
Is there any "...
Hi,
I have JTextAreas and need to get chars, which are added, removed or changed to it. How do I do this?
...