different output trying to execute same java code
i am using net beans 7 ide and java 6 to develop my java projects. i used the following coding to read value from serial port :
import java.io.*;
import java.util.*;
import javax.comm.*;
public class SimpleRead implements Runnable, SerialPortEventListener {
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
public static void main(String[] args) {
portList = CommPortIdentifier.getPortIdentifiers();
JOptionPane.showMessageDialog(null, "portList :"+portList.hasMoreElements());
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals("COM3")) {
// if (portId.getName().equals("/dev/term/a")) {
SimpleRead reader = new SimpleRead();
}
}
}
}
public SimpleRead() {
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
} catch (PortInUseException e) {System.out.println(e);}
try {
inputStream = serialPort.getInputStream();
} catch (IOException e) {System.out.println(e);}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {System.out.println(e);}
serialPort.notifyOnDataAvailable(true);
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {System.out.println(e);}
readThread = new Thread(this);
readThread.start();
}
public void run() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {System.out.println(e);}
}
public void serialEvent(SerialPortEvent event) {
switch(event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
byte[] readBuffer = new byte[20];
try {
while (inputStream.available() > 0) {
int numBytes = inputStream.read(readBuffer);
}
System.out.print(new String(readBuffer));
} catch (IOException e) {System.out.println(e);}
break;
}
}
}
When i execute from netbeans, JOptionPane showing "portList : true" but when i double click on the jar file and tried to run, JOptionPane showing " portList : false"
Why there is different output trying to execute same java code
View Answers
Related Tutorials/Questions & Answers:
different output trying to execute same java code there is
different output trying to
execute same java code...
different output trying to
execute same java code i am using net beans 7 ide and
java 6 to develop my
java projects. i used the following coding
different output trying to execute same java codedifferent output trying to
execute same java code i am using net beans 7 ide and
java 6 to develop my
java projects. i used the following coding... " portList : false"
Why there is
different output trying to
execute same java Advertisements
different output trying to execute same java codedifferent output trying to
execute same java code i am using net beans 7 ide and
java 6 to develop my
java projects. i used the following coding... " portList : false"
Why there is
different output trying to
execute same java Java error cannot find symbol and
execute the program
output
will be as below
Description : In the above...
Java error cannot find symbol
In this section you will learn about "cannot find symbol" in
java.
Java
cannot find symbol is a type of error occurs
Servlet signup same output - JSP-ServletServlet signup
same output Ok i solved the problem of content type by res.setContentType("text/plain"), but the
output is
same it always prints....
Hi friend,
Plz give full details with source
code to solve
how to execute this code - JSP-Servlethow to
execute this code hi guys can any help me in executing this bank application http://www.roseindia.net/jsp/bank.shtml, i need to use any database plz tell me step-to-step procedure for executing this,i need to create
inserting same data to different tables in oracleinserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
how to distinguish engines having same code - Struts introduced a new engine for testing purpose it has almost
same code as previous engine...how to distinguish engines having
same code hi we are using struts... as both access
same database .file is kept in central repository
both engine
Does finally always execute in Java?Does finally always
execute in
Java? Hi,
I am learning exception handling in
Java. I want to know if finally{} block is always executed or not in
Java?
Does finally always
execute in
Java?
Thanks
Does finally always execute in Java?Does finally always
execute in
Java? Hi,
I am learning exception handling in
Java. I want to know if finally{} block is always executed or not in
Java?
Does finally always
execute in
Java?
Thanks
Does finally always execute in Java?Does finally always
execute in
Java? Hi,
I am learning exception handling in
Java. I want to know if finally{} block is always executed or not in
Java?
Does finally always
execute in
Java?
Thanks
how to execute a unix shell script from a java program the script name from a
java code .once you
execute this
java program...how to
execute a unix shell script from a
java program well , i am... solution . could anyone please give a sample
code as of how to do this...
what i am
Java Execute Jar file operating system or platform.
To
execute a JAR file, one must have
Java installed in their computer. Also the version of the
Java should be up-to-date, so...JAR stands for
Java ARchive and is platform independent. By making all
Are J2EE and Java Advanced the same?Are J2EE and
Java Advanced the
same? Hi,
I am checking J2EE and Advanced
Java. Are J2EE and
Java Advanced the
same?
Thanks
Hi,
J2EE is now renamed to JEE in latest version of
Java platform, which is Specification
output java - Java Beginners;
}
a. what is the
output of the ff.
java statement:?
i. System.out.println (secret...
output java public static int secret(int one)
{
int i;
int...? Hello
Are you beginner?
Ok, The first
Output is 125
Multithreading in JavaMultithreading in
java is running multiple threads sharing
same address space... and
execute these
different tasks simultaneously.
Following are 4 states... to
execute them at the
same time.
Following is an example of Multithreading:
public