i used a coding for getting data from serial port. JOptionbox with "port not found" message is shown when i execute thru jar file. but when i execute thru netbeans, data is received from comm port. why it is happening? i attached the coding i used.
public class SimpleRead implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread;
public static void main(String[] args) { boolean portFound = false; String defaultPort = "COM2";
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(defaultPort)) {
JOptionPane.showMessageDialog("Found port: "+defaultPort);
portFound = true;
SimpleRead reader = new SimpleRead();
}
}
}
if (!portFound) {
JOptionPane.showMessageDialog("port " + defaultPort + " not found.");
}
}
private int numBytes; private String s;
public SimpleRead() { try { serialPort = (SerialPort) portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) { System.out.println("port in use"); }
try { System.out.println("Getting input Stream"); 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) {}
readThread = new Thread(this); readThread.start(); }
public void run() { try { Thread.sleep(2000); } catch (InterruptedException 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.OUTPUTBUFFEREMPTY: break;
case SerialPortEvent.DATA_AVAILABLE:
byte[] readBuffer = new byte[8];
byte[] readBuffer2=null;
try {
while (inputStream.available() > 0) {
numBytes = inputStream.read(readBuffer);
readBuffer2= new byte[numBytes];
for(int i=0;i }
}
}}
s = new String(readBuffer2);
System.out.println("readbuffer......"+ s);
} catch (IOException e) {}
break;
jar file not reading input from serial port i used a coding for getting data from serial port. JOptionbox with "port not found" message is shown when i execute thru jar file. but when i execute thru netbeans, data is received
jar file not reading input from serial port i used a coding for getting data from serial port. JOptionbox with "port not found" message is shown when i execute thru jar file. but when i execute thru netbeans, data is received
Reading a file from Jar JAVA I have added one excel sheet into a jar file.
can anybody tell me how i can read that file.
actually when i am running code from eclipse i able to read it but when i am adding that jar file
Reading a file from Jar JAVA I have added one excel sheet into a jar file.
can anybody tell me how i can read that file.
actually when i am running code from eclipse i able to read it but when i am adding that jar file
Reading string from file timed So I want to make a file reader/ buffered reader that reads a new line of the textfile, lets say every 30 second.
Like it reads the first line, waiting 30 seconds, read the next line and so one
reading dropdown values from properties file in jsp reading dropdown values from properties file in jsp
Reading text from image file How Read text from image file
reading a csv file from a particular row how to read a csv file from a particular row and storing data to sql server by using jsp servlet
Writing to and reading from a binary file in java. I have written... the binary file from another program as follows:
m_dis = new DataInputStream... work, but the records obtained after reading the binary file are much less than
initialise array by reading from file Hello, I wnat to know how i would initialise an array by reading a text file, which contains a simple pattern.
for example the file may look as shown below, with the star character
reading data from excel file and plotting graph I am doing a project using NetBeans in which i have to take input an excel file and then using... at the same time from one excel file using different columns..how can i do that?
waiting
Java Read username, password and port from properties file
In this section, you will come to know how to read username, password and port no from the properties file and display the data from the database. Now to load the data from
Count repetitions of every word from an input file Hello..i got to know how can i count the repetitions of every word present in a specific input file?For suppose if i have a url log file which have time,url's,ip address etc
serial port communication using bluetooth in j2me how to make serial port communication using bluetooth in j2me ?
what r prerequisites
serial port communication using bluetooth in j2me how to make serial port communication using bluetooth in j2me ?
what r prerequisites
How to create file from input values in Jframe ? hi i m doing my project using java desktop application in netbeans.i designed a form to get... to take these details and make a file that can be appended each time.how
Reading duplicate keys from .properties file Hi,
I am reading a .properties file using a basic java program.Though the .properties file will not allow duplicate keys, but still I want to develope a program to identify
find jar file name from multiple set of jar files I would like to find jar file name from multiple set of jar files where the given class nameââ?¬Â?com.rational.ft.util.debugââ?¬Â
Serial COM Port Value in to database How save the serial COMport value in mysql databse.
Following code is here.
package simpleread;
import...();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL
reading multiple files from a directory and writing them into a single file... file i get an empty text file can you guide me how to do this:
/*this program reads multiple files
* from a single directory. */
package elite.tech.com
Java error reading from file
Java error reading file...
reading from file. For this we have a class error reading from file. Inside
reading the records from a .xlsx file and storing those records in database table Here is my requirement, I want to read the records from a .xlsx file and store that records in database table.
I tried like this
public class
Writing a Program to calculate Circumference of planets reading from a file... a program to read data from a file. Then use the numerical data within... stumped when it comes to reading the file and writing to a new file.
My code
Reading XML from a File
This Example shows you how to Load Properties from the XML file via... to
create new DOM parsers. Some of the methods used for reading XML from a 
Reading the data from property file from java stand alone application in linux Please send me the example of reading the data from a property file from java stand alone application in linux. I don't know how to give path
jar file built by ant jar task does not have all the dependant jars and throws exception while reading the appplicationContext,xml I have a spring...;/target>
While executing the jar file using java -jar command it is throwing
Writing a Program to calculate Circumference of planets reading from a file... a program to read data from a file. Then use the numerical data within... it comes to reading the file and writing to a new file. My code is as follows
ModuleNotFoundError: No module named 'USPP-Universal-Serial-Port-Python-Library...:
ModuleNotFoundError: No module named 'USPP-Universal-Serial-Port-Python-Library...-Serial-Port-Python-Library python with following command:
pip install USPP
how to delete a jar file from mobile by using j2me program. When i'll update a new version jar in mobile. Then i want to delete that old jar which is previously present in mobile. How to do
svg file reading and display i want a sample program for reading and displaying the content of a svg file
Reading a text file in java What is the code for Reading a text file... in java.io.* package for reading and writing to a file in Java.
To learn more about reading text file in Java see the tutorial Read File in Java.
Thanks
JAR FILE WHAT IS JAR FILE,EXPLAIN IN DETAIL?
A JAR file... and applications.
The Java Archive (JAR) file format enables to bundle multiple... link:
Jar File Explanation
jar file how to run a java file by making it a desktop icon i need complete procedur ..through cmd
input stream and byte output stream. This is and
good example of reading file...
In this example we have used the class InputStream
for reading the file...
import java.io.*;
/**
* Example of Reading file into byte array
Thread for reading txt file how to use 3 thread to read 3 txt file?
To create three threads for reading the file and three threads for getting the strings out of the queue and printing them.
thanks
Problem reading word file Deepak you provide me code for extarcting equation from a word file and also to write in a word file.But when I again want to read preveously created word file(created by your code) it gives an error
Reading big file in Java How to read a big text file in Java program?
Hi,
Read the complete tutorial at How to read big file line by line in java?
Thanks
Reading Value From console In case of String data Type readLine method of DataInputStream class
read complete line of the given string but the next method of Scanner
class doesn't read the complete line of String. why
Reading Value From console In case of String data Type readLine method of DataInputStream class
read complete line of the given string but the next method of Scanner
class doesn't read the complete line of String. why
reading from pdf how can i read specific words from pdf file?
Java Read pdf file
import java.io.*;
import java.util.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
public class ReadPDF {
public
and reading data from file for our assignment, but just stuck on how to proceed... the user input from the user through GUI components and store the data...;To extract the data from text file and save it to jtable, visit the following links
Reading an excel file into array Hi,
I'm trying to read in an excel file, search a column for containing key words (entered by a user) and then displaying the matching rows in a table. I'm fairly new to JavaScript. Can anyone
External file reading in jsp i have written a jsp page(ReadExt.jsp) in my application which reads a text file content from a system... file. It uses BufferedReader class to read that particular file.
<%@ page
External file reading in jsp i have written a jsp page(ReadExt.jsp) in my application
which reads a text file content from a system...; The given code reads the given file. It uses BufferedReader class to read
Reading a big file effeciently How to read a large text file quickly without memory error in Java?
What is the best method to read a big file very efficiently?
Thanks
Hi,
Kindly check the program Java Read File
File path for jar file Hi Experts,
I have created one eclipse... jar file of that application, unfortunately it is giving the error that resource not found for the template file.
Also I had tried to get that path from user
Best way to reading file in java Hi,
As a beginner I want to learn about Java programming and make a program for reading a text file in java. What is the best way for reading file in Java?
Thanks