|
anyone can help me here please :
Handling Biometric Fingerprint Attendance Device by using Socket (JAVA) Is that possible?! I try with Socket, BUT it does not executed with me!
Me Code is:
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
public class Requester {
Socket requestSocket;
ObjectOutputStream out;
ObjectInputStream in;
String message;
Requester() {
}
void run() throws IOException {
try {
requestSocket = new Socket("192.168.0.19", 4370);
System.out.println("Connected to given host in port 4370");
in = new ObjectInputStream(requestSocket.getInputStream());
String line;
while (true) {
line = in.readLine();
if (line != null) {
System.out.println(line);
}
}
} catch (UnknownHostException unknownHost) {
System.err.println("You are trying to connect to an unknown host!");
} catch (IOException ioException) {
ioException.printStackTrace();
} catch (Exception Exception) {
Exception.printStackTrace();
} finally {
in.close();
requestSocket.close();
}
}
void sendMessage(String msg) {
try {
out.writeObject(msg);
out.flush();
System.out.println("client: " + msg);
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
public static void main(String args[]) throws IOException {
Requester client = new Requester();
client.run();
}
}
f anyone could help me to communicate with the finger print device I will be grateful.
modified 4-Jun-14 3:55am.
|
|
|
|
|
Please refer to point 9 of the forum guidelines above.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
|
What does "it does not executed with me" mean; we cannot guess from this what is going wrong? Have you checked the documentation for the device to make sure your protocol is correct?
|
|
|
|
|
sure I checked the documentation very well, and I am sure from the port number and IP address are correct! I mean BY "it does not executed with me" It can not read from the device, just connect and wait for response from the device without hope to retrieve the data I do not know where is the error in my code !!
|
|
|
|
|
Maheera Jazi wrote: I do not know where is the error in my code Well you need to use your debugger to check what is happening internally. But, more importantly, you need to be sure that the device is functioning correctly, and communicating with your PC. And for that you need to contact the device manufacturer for help.
|
|
|
|
|
yes, thanks for your response please.But, question please, you mean that it is possible to use Socket Object to retrieve the data from Fingerprint attendance machine?! as in my code!?
|
|
|
|
|
Maheera Jazi wrote: you mean that it is possible to use Socket Object to retrieve the data from Fingerprint attendance machine?! No idea. As I keep saying, you must read the documentation for the device; we have no idea how it works.
|
|
|
|
|
ok, thanks! although this is not mentioned on the device documentation! I will try all roads!
|
|
|
|
|
Forget what is not mentioned and focus on what is. You cannot create an application to use this device by guesswork, you need to study the documentation and follow what is says. If the documentation is not clear then go back to the manufacturers and ask for help.
|
|
|
|
|
Hi everyone,
I have 1 question here?
Is there any way to call public method of a child thread from its parent class
from where it is created
eg.
public class ChildThread implements Runnable{
public ChildThread(){
}
public void run(){
}
public void doMethod(){
}
}
Now I'm creating multiple ChildThread in AnotherClass
public class Parent {
Thread t;
//variables
public Parent(){
//initialization
}
//statements
private someParentMethod{
//for some event1
t=new Thread(new ChildThread(),"name1");
t.start();
}
private doSomething(){
//some event1 for name1
//want to call doMethod() of ClildThread name1
}
}
|
|
|
|
|
Short answer: YES.
long answer:
I would recommend to use childThread direct and a null-check before using the member variable t:
public class ChildThread extends Thread{
public ChildThread(String name){
super(name);
}
public void run(){
}
public void doMethod(){
}
}
public class Parent {
ChildThread t;
public Parent(){
}
private someParentMethod{
t=new ChildThread("name1");
t.start();
}
private doSomething(){
if(t != null){
t.doMethod();
}
}
}
regards Torsten
I never finish anyth...
|
|
|
|
|
krishna_m wrote: Is there any way to call public method of a child thread from its parent class
Yes but I am guessing that you really do not want to do that.
Typically different threads do not communicate except very explicitly. Note that I said "thread" not class. If you want a thread to communicate with another thread then you first figure out what the best way to do that is and THEN you figure out which classes will do it (and how.)
|
|
|
|
|
hi everyone,
I need java program for converting pdf file into excel file. please help me.
|
|
|
|
|
|
1. find a library that reads pdfs.
2. Find a library that writes excel files.
3. Spend a LOT of time figuring out what to do with all the differences between pdfs and excel file.
4. Write code that implement 3 and uses 1 and 2.
|
|
|
|
|
|
How does that convert PDF to Excel?
|
|
|
|
|
Hi colleague developers,
I've got a problem in communicating with serial port. In my applcation I have to receive some data from the serial port and to manage them for some operation. For now I'm just trying to write out the data received.
I've create a test class with main() that manage the connection (open the port, set the parameters) and starts a thread. The thread is started in this manner:
try {
(new Thread(new Lettore(port), "Lettore")).start();
} catch (Exception e) {
System.err.println("Errore " + e);
}
where the "port"parameter is the SerialPort object.
The "Lettore" class contains the follow:
SerialPort port;
public Lettore(SerialPort port) throws IOException {
this.port = port;
}
@Override
public void run() {
byte[] buffer = new byte[1024];
int len = -1;
try {
while (true) {
len = port.getInputStream().read(buffer);
System.out.print(new String(buffer, 0, len));
if (len != 0) {
port.getOutputStream().write(buffer, 0, len);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
In this case, the code in the thread seems to be never executed: no characters are show on the terminal and on the other station of the communication. On the other hand, if I write the same code of the run() function in the main, it works fine.
Someone has ever got this problem? Can anyone help me?
modified 27-May-14 3:57am.
|
|
|
|
|
|
Dear Richard,
thanks for the reply. I made the thread runnable by "implements Runnable" on the "Lettore" class definition, now it works. Thank you very much!
The final code is this:
public class Lettore implements Runnable {
SerialPort port;
public Lettore(SerialPort port) throws IOException {
this.port = port;
}
@Override
public void run() {
byte[] buffer = new byte[1024];
int len = -1;
try {
while (true) {
len = port.getInputStream().read(buffer);
System.out.print(new String(buffer, 0, len));
if (len != 0) {
port.getOutputStream().write(buffer, 0, len);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
|
|
|
|
|
Hi guys, i wrote a desktop programm, that can send sms using a modem via seriaport...on netbeans i run my programm all is ok...i receive my sms on my phone!!...but once a creat an .exe, then i get error reported, i don't understand why...i don't know what to do, i've created my .exe using excelsior jet, and comm.jar for reading serial port....on netbeans i can easely clean and build my project , but once the .exe done i ain't get nothing ...please help!!..
|
|
|
|
|
mtouxx wrote: please help With what? We know nothing about your program except that it does not work. Why not try running it as a proper Java class so you can use the debugger to find out what the problem is?
|
|
|
|
|
|
I want to know, to what extend a XML file can store data???
Means the string limitations, data types and so on.....
-Toywarrior
modified 21-Nov-20 21:01pm.
|
|
|
|