java

How can we connect a mobile to a pc using a Java program.?

I'd like to write a JAVA program that connects my mobile with PC through a USB cable. How do I go about it?? ...

How to get a unique computer identifier in Java (like disk id or motherboard id)

Hi, I'd like to get an id unique to a computer with Java, on Windows, MacOS and if possible, linux. It could be a disk UUID, motherboard s/n... Runtime.getRuntime().exec can be used (it is not an applet). Ideas ? ...

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException when using JDBC to access remote MySQL database

/** * */ package ORM; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; /** * @author Gwilym * @version 0.0 */ public class DatabaseConnection { private String userName=""; private String password=""; private String host=""; Connection conn; /** * @param userName * @param passwo...

Declaring array variables

Hey guys, got a problem with a question. Question : Write a declaration for a variable people that could be used to refer to an Array of objects of type Person My answer: public people[]; people = new Person [100]; But I am getting an error saying it is wrong. What am I doing wrong? PS. I also tried public people[] = new Person [10...

tf idf similarity problem

Hi All, i am using TF/IDF to calculate similarity. For example if i have following two doc. Doc A => cat dog Doc B => dog sparrow It is normal it's similarity would be 50% but when I calculate its TF/IDF. It is as follow Tf values for Doc A dog tf = 0.5 cat tf = 0.5 Tf values for Doc B dog tf = 0.5 sparrow tf = 0.5 IDF values for D...

ResultSet to Pagination

How do I convert Resultset object to a paginated view on a JSP? For example, this is my query and result set: pst = con.prepareStatement("select userName, job, place from contact"); rs = pst.executeQuery(); ...

How to wait for object creation in EDT without blocking EDT?

I am using an API in a Java library which is called from the event dispatch thread and requires me to return a fully-initialized UI component. It looks like this: public JDialog createDialog(); But I can only populate the dialog after loading from a database, which can take 10 seconds sometimes. Normally I would do that in a backgrou...

Initialising Array Variables

I got a problem with a question. Question: an Array instance variable called people has been set up by the line: public Person[] people; Write the line that will initialise/instantiate it to take 100 objects of type Person. My answer: public Person[] people; double []people = new Person [100];` The error that I am gettin...

How to work with Weblogic in Eclipse?

What are the recommended plugins for eclipse to work with weblogic? Specifically I would need to work with older version of weblogic, 8.1, however I could use any version of Ecplise. I would like to debug the application and set breakpoints etc. My bigger task is to move the project over to Jboss, can I deploy the same app on both app s...

Binary search, from java to Actionscript

Hi I am trying to convert the following java binary search routine to as3. I assume that 'compareTo' is a built in java method and that '>>>' s a type of bitwise operation. Can anyone familiar with both actionscript 3 and Java help with this? package binary; public class Finder { public static int find( String[ ] keys, String targe...

Array Instantiation

Can you help me out with this question please. Question: Given the following array declarations double readings[]; String urls[]; TicketMachine[] machines; write assignments that accomplish the following tasks: make the readings variable refer to an array that is able to hold sixty double values make the urls variable refer to an ...

java byte data type

In Sun' tutorial it says about a byte: byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where the...

Is there a convention, when using Java RMI, to use the dollar sign $ in a variable name?

I realize that it is a valid part of a variable name, but I've never seen variable names actually use the symbol $ before. The Java tutorial says this: Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable ...

Substring search in Java

i am having a problem with string comparison. For example, I have this string: "hello world i am from heaven" I want to search if this string contains "world". I used following functions but they have some problems. I used String.indexof() but if i will try to search for "w" it will say it exists. In short i think i am looking for ex...

Porting Java SE Game to Java ME

Hey all, I'm learning to program in Java and would like to develop a mobile Chess game for the Blackberry platform. It was recommended to me that, as a beginner, I should build the game for regular desktop use and avoid the more complex mobile development for now. I was told that I can port the game to Java ME once development in SE i...

create a permission bit mask in java

I want to do something like this: public enum Permissions { CanBlah1, CanBlah2, CanBlah3 } byte[] userPerm = Permissions.CanBlah1 | Permissions.CanBlah2; // check permssions // if(userPerm && Permissions.CanBlah1 == Permissions.CanBlah1) { // do something } Can you do this in Java like that? (I'm coming from a c# b...

Full stack framework for Java

Hello everyone, I'm looking for a full stack framework (from persistency to view generation (CRUD)) for Java. I don't have experience with Rails style frameworks, like Grails, but I worked a lot with Hibernate, Struts, Spring ... I prefer a framework that let you naturally modify the business domain design with the less effort ( i.e. w...

How do debug in Eclipse when an object is invoked?

Hi, I have just started with java development using Eclipse, when I was debugging this part: object.methodInAnotherClass(parameters); The debugger stopped, I understand this won't skip to another class and start debugging that, but what is the other way I can debug my another class? The same problem is also in CORBA. So, what is th...

what are java executable format both in unix and windows

I know about class/jar executable format. But jar/class can not ensure source security, because java source code(.java) can retrieve from it. I am looking for such a format where source are secure/un-retrievable. ...

Java: Equalator? (removing duplicates from a collection of objects)

I have a bunch of objects of a class Puzzle. I have overridden equals() and hashCode(). When it comes time to present the solutions to the user, I'd like to filter out all the Puzzles that are "similar" (by the standard I have defined), so the user only sees one of each. Similarity is transitive. Example: Result of computations: A ...