Results 1 to 16 of 16
  1. #1
    livnihai is offline Member
    Join Date
    Sep 2009
    Posts
    18
    Rep Power
    0

    Default code run with eclipse but not with bat file

    this is the bat file

    java reading_and_writing_event_driven.Seriallogger
    pause



    package reading_and_writing_event_driven;

    import java.io.*;

    import javax.comm.*;

    import java.util.*;

    public class Seriallogger {

    /**
    * @param args
    */
    public static void main(String[] args)
    throws IOException, NoSuchPortException,
    PortInUseException, UnsupportedCommOperationException{
    // TODO Auto-generated method stub
    new Seriallogger();
    }

    public Seriallogger()
    throws IOException, NoSuchPortException,
    PortInUseException, UnsupportedCommOperationException{
    Enumeration pList = CommPortIdentifier.getPortIdentifiers();

    while (pList.hasMoreElements()){
    CommPortIdentifier cpi = (CommPortIdentifier)pList.nextElement();
    String name = cpi.getName();
    System.out.println("Port " + name + " ");
    if(cpi.getPortType() == CommPortIdentifier.PORT_SERIAL){
    System.out.println("is a Serial Port: " + cpi);
    SerialPort thePort;
    try{
    thePort = (SerialPort)cpi.open("Logger", 1000);
    }catch (PortInUseException ev){
    System.err.println("Port in use: " + name);
    continue;
    }

    thePort.notifyOnDataAvailable(true);
    try{
    thePort.addEventListener(new Logger(cpi.getName(), thePort));
    }catch (TooManyListenersException ev){
    System.err.println("Too many listeners(!) " + ev);
    System.exit(0);
    }
    }
    }
    }
    }

    //page 330 programming Serial and parallel ports.pdf
    package reading_and_writing_event_driven;

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    import javax.comm.SerialPort;
    import javax.comm.SerialPortEvent;
    import javax.comm.SerialPortEventListener;

    public class Logger implements SerialPortEventListener{
    String portName;
    SerialPort thePort;
    BufferedReader ifile;

    public Logger(String name, SerialPort port)
    throws IOException{
    portName = name;
    thePort = port;
    ifile = new BufferedReader(new InputStreamReader(thePort.getInputStream()));
    }

    public void serialEvent(SerialPortEvent ev){
    String line;
    try{
    line = ifile.readLine();
    if (line == null){
    System.out.println("EOF on serial port.");
    System.exit(0);
    }
    System.out.println(portName + ": " + line);
    } catch (IOException ex){
    System.err.println("IO Error " + ex);
    }
    }
    }

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    What is your question?

  3. #3
    livnihai is offline Member
    Join Date
    Sep 2009
    Posts
    18
    Rep Power
    0

    Default

    The question is,
    why does to code run from inside the eclipse and
    doesn't run when i try to run it with a bat file
    thanks

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    What happens when you try it with a bat file?

  5. #5
    livnihai is offline Member
    Join Date
    Sep 2009
    Posts
    18
    Rep Power
    0

    Default

    Hi, i get a cmd window error
    D:\Java\workspace\Serial Tests\bin>java reading_and_writing_event_driven.Serialloger
    Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisParallel in java.library.path
    Caught java.lang.UnsatisfiedLinkError: com.sun.comm.SolarisDriver.readRegistrySerial
    <Ljava/util/Vector;Ljava/lang/String;> I while loading driver com.sun.comm.solarisDriver

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Do you have the mentioned library then? Provide it's path to the program. Did you add it to the eclipse project when you got it to work on Eclipse?

  7. #7
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    804
    Rep Power
    6

    Default

    Go thru this below article whether it helps u for "Unstatisfied link error"
    Troubleshooting: java.lang.UnsatisfiedLinkError
    Ramya:cool:

  8. #8
    livnihai is offline Member
    Join Date
    Sep 2009
    Posts
    18
    Rep Power
    0

    Default

    I did, and it's working when i run from the eclipse

  9. #9
    livnihai is offline Member
    Join Date
    Sep 2009
    Posts
    18
    Rep Power
    0

    Default

    Basicly I need that my program to work when it get a signal from the serial port, maybe there is a simple way

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  11. #11
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Quote Originally Posted by livnihai View Post
    I did, and it's working when i run from the eclipse
    What do you mean by "I did" above? Do you mean you did add it to eclipse when you ran the program in eclipse?

  12. #12
    livnihai is offline Member
    Join Date
    Sep 2009
    Posts
    18
    Rep Power
    0

    Default

    add the jars as libraries by going to Project Properties -> Java Build Path -> Add External JARs. (comm.jar)

  13. #13
    livnihai is offline Member
    Join Date
    Sep 2009
    Posts
    18
    Rep Power
    0

    Default

    Befor I've added comm.jar, i had import javax.comm can't be resolve
    after that it work good iside the eclipse.
    But now I can't do from a bat file as I said above

  14. #14
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Not the jars. I mean the library that is missing. Is it in the jar? Read the error message again. It tells you what is missing. If you have the required required library then you need to load it using System.loadLibrary.

  15. #15
    livnihai is offline Member
    Join Date
    Sep 2009
    Posts
    18
    Rep Power
    0

    Default

    First of all, thank you for your patience.

    How do I add what l library, SolarisParallel in java.library.path?

    by the way, why does it say "SolarisParallel"? I'm working with Vista

    thanks

  16. #16
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    I have no idea why it says SolarisParallel.
    Maybe set the java.library.path in your script to point to the path where the library is and do a System.loadLibrary providing the name of the library to load.

Similar Threads

  1. help to run java Qr Code by eclipse
    By elaseef in forum Eclipse
    Replies: 1
    Last Post: 08-13-2009, 08:56 PM
  2. Eclipse Bug - Can't Read From A File Using Eclipse?
    By carlodelmundo in forum New To Java
    Replies: 6
    Last Post: 01-26-2009, 04:25 PM
  3. Complete code won't run in eclipse
    By confusedStudent in forum New To Java
    Replies: 2
    Last Post: 12-19-2008, 08:43 AM
  4. how to debug java code in eclipse
    By rajesh058 in forum Advanced Java
    Replies: 3
    Last Post: 07-25-2007, 11:19 PM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •