|
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.
|
|
|
|
|
Limitations are based on users of the xml not the xml itself.
1. Java can't have a string greater than Integer.MAX (or whatever it is called.)
2. A file can't be bigger than the file system.
3. Java can't occupy more than the allowed user addressable space.
For the second of the above if you are close to those limits than it is unlikely that an XML file is an optimal choice for data storage.
|
|
|
|
|
Message Closed
modified 21-Nov-20 21:01pm.
|
|
|
|
|
Shrikshel wrote: can I actually store images(any medai) in XML file You could, but that is not what XML was designed for. Images are better stored as files, or BLOBs in a database.
|
|
|
|
|
OK. Thanks.
-Toywarrior
modified 21-Nov-20 21:01pm.
|
|
|
|
|
Shrikshel wrote: So, can I actually store images(any medai) in XML file
Can you - yes.
Should you - I seriously doubt it.
Without knowing any thing about what you are doing and presuming you don't want to use a database then if it was me I would use files for each image and perhaps keep meta data in the xml file (such as a pointer to the file path on the file system.) Keeping in mind however that doing that is basically the same as creating a database.
|
|
|
|