Results 1 to 1 of 1
- 10-04-2009, 02:47 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 18
- Rep Power
- 0
Problem: program runs with eclipse not with dat file
Hi,
I have this program that runs with eclipse fine,
but it dosn't run with the bat file.
The Exception is NoClassDefFoundError: javax/comm/SerialPort/EventLstener.
another class in the package runs good with the bat file
The bat file is
[code]
java newGUIandSerial.SimpleRead
pause
[\code]
The code is:
[code]
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();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
SimpleRead reader = new SimpleRead();
// if (portId.getName().equals("COM1")) {
if (portId.getName().equals("/dev/term/a")) {
reader = new SimpleRead();
}
}
}
}
public SimpleRead() {
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
} catch (PortInUseException e) {}
try {
inputStream = serialPort.getInputStream();
} catch (IOException e) {}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException 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(20000);
} catch (InterruptedException e) {}
}
public void serialEvent(SerialPortEvent event) {
switch(event.getEventType()) {
case SerialPortEvent.DATA_AVAILABLE:
byte[] readBuffer = new byte[20];
int numBytes;
try {
numBytes = inputStream.read(readBuffer);
System.out.println(numBytes);
if (numBytes == 14){
System.out.println("שיחקתי אותה");
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
// if (inputStream.available() > 0)
// System.out.print(new String(readBuffer));
while (inputStream.available() > 0) {
numBytes = inputStream.read(readBuffer);
}
// System.out.print(new String(readBuffer));
} catch (IOException e) {}
break;
}
}
}
[\code]
thanks
Similar Threads
-
java.util.Scanner runs in Vista but not in Linux
By pellebye in forum New To JavaReplies: 6Last Post: 08-24-2009, 03:50 AM -
[SOLVED] App runs only in IDE
By hannehomuth in forum Advanced JavaReplies: 4Last Post: 07-15-2009, 06:41 PM -
Opening file, runs in NetBeans but CommandPrompt
By fauzilhaqqi in forum NetBeansReplies: 2Last Post: 12-15-2008, 03:48 AM -
Program Runs in NetBEans but Not in cmd
By MeathUltra in forum NetBeansReplies: 1Last Post: 12-09-2008, 05:38 AM -
Q:App development that runs in a browser, also as a desktop on all platforms
By gsmurthy30 in forum New To JavaReplies: 2Last Post: 09-12-2008, 06:10 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks