Interfacing a java program with hardware

I need to be able to interface a java program
with data in the parallel or serial ports of the computer.
I have no idea how to go about this, could someone please help me.
Thanks

http://java.sun.com/products/javacomm/

Similar Messages

  • Interfacing a java program with other programs

    Hi there.
    I'm curently working on a project which will involve communication between a java program (the project) and other programs, not necessarily in java.
    I know there is the good old "socket method" to handle the communication, but ... are there any other methods ?
    Thanks for help.

    Communication... what's that?
    Have the two programs share a database. Have them send e-mails to each other... the list goes on.

  • How can i run my java program with out java language

    Hai to every one ..Iam new to java language ...am using windows xp operating system , i did not installed java language in my system .. how can i run a java program with out installing java language... Which files is requied to run java program..?
    any one can help me??

    Hai to every one ..Iam new to java language ...am
    using windows xp operating system , i did not
    installed java language in my system .. how can i run
    a java program with out installing java language...
    you ... can ... not ... do ... this
    Which files is requied to run java program..?
    any one can help me??a JVM. Download it from sun's website.
    [url http://java.sun.com/javase/downloads/index.jsp]Download JavaSE here

  • How to run a standalone java program with JRC to display/run a report

    Hi All,
    I am new to this forum.
    I am trying to run a java program developed using JRC to run a report created using Crystal Report XI. I stucked because not knowing how to run that java program.
    Can anyone help me? or
    can give a simple java code to do the same.
    Thanks in advance.
    Saravanakumar.

    Hi Saravana
    For the steps to run a standalone application java program with JRC to display/run a report ,please refer the following link.
    http://support.businessobjects.com/communityCS/TechnicalPapers/cr_xi_r2_jrc_deployment.pdf.asp
    You can get the sample code for standalone/desktop applications from the following link.
    http://support.businessobjects.com/communityCS/FilesAndUpdates/crxi_r2_jrc_desktop_samples.zip.asp
    Please do revert in case of any queries.
    Thanks
    Soni

  • Starting Java Program with a bash Shell script

    Hi !
    I know this is a Linux query but I am putting it on this site to get different answers.
    I want to start my Java program with a shell script. Can anybody give me a proper script to start my Java program?
    I am using RH Linux 7.3 and JDK 1.4.
    Can I start the Java program without starting the terminal? Just like the Sun One Studio4 'runide.sh' script.
    Please help.
    Bye Niteen

    assuming you have your PATH and CLASSPATH variables set correctly, your script should look like this:
    #!/bin/bash
    cd <project_dir>
    java <class> &
    example:
    #!/bin/bash
    cd ~/projects
    java project1.main_package.MainClass &
    of course you could add some more elaborated stuff like compiling files before running the program, etc.
    if you dont like terminals, try running "nautilus" (it's like Windows Explorer). i never use nautilus (especially for running scripts), so i cant guarantee it will work, although i dont see why it shouldnt...

  • Java Program with Adapter / Facade Pattern

    Hey All:
    I'm very new to the Java language and have been given a fairly complicated (to me) program to do for a course I'm taking. The following is the scenario. I'll post code examples I have and any help will be greatly appreciated. Let me apologize ahead of time for all the code involved and say thank you in advance :).
    The program is the follow the following logic:
    Organizations A's Client (Org_A_Client.java) uses Organization A's interface (Org_A_Interface.java) but we want A's Client to also be able to use Organization B's services as well (Org_B_FileAuthorMgr.java, Org_B_FileDateMgr.java, Org_B_FileIOMgr.java).
    Now a portion of this program also involves validating an xml file to it's dtd, extracting information from that source xml file through the use of a XMLTransformation file, and applying the transformation to produce a targetxml file which is then validated against a target DTD. (I've done this portion as I have a much better understanding of XML).
    At this point we have been given the following java classes:
    Org_A_Client.java
    package project4;
    /* This class is the Organization A Client.
    It reads a source xml file as input and it invokes methods defined in the
    Org_A_Doc_Interface Interface on a class that implements that interface */
    import java.io.*;
    import java.util.Scanner;
    public class Org_A_Client {
         // Define a document object of type Org_A_Doc_Interface
         private Org_A_Doc_Interface document;
         // The Org_A_Client constructor
         public Org_A_Client() {
              // Instanciate the document object with a class that implements the
              // Org_A_Doc_Interface
              this.document = new Adapter();
         // The Main Method
         public static void main(String Args[]) {
              // Instanciate a Client Object
              Org_A_Client client = new Org_A_Client();
              // Create a string to store user input
              String inputFile = null;
              System.out.print("Input file name: ");
              // Read the Source xml file name provided as a command line argument
              Scanner scanner = new Scanner(System.in);
              inputFile = scanner.next();
              // Create a string to store user input
              String fileID = null;
              System.out.print("Input file ID: ");
              // Read the Source xml file name provided as a command line argument
              fileID = scanner.next();
              //Convert the String fileID to an integer value
              int intFileID = Integer.parseInt(fileID);
              if (inputFile != null && !inputFile.equals("")) {
                   // Create and empty string to store the source xml file
                   String file = "";
                   try {
                        // Open the file
                        FileInputStream fstream = new FileInputStream(inputFile);
                        // Convert our input stream to a
                        // BufferedReader
                        BufferedReader d = new BufferedReader(new InputStreamReader(
                                  fstream));
                        // Continue to read lines while
                        // there are still some left to read
                        String temp = "";
                        while ((temp = d.readLine()) != null) {
                             // Add file contents to a String
                             file = file + temp;
                        d.close();
                        // The Client Calls the archiveDoc Method on the Org_A_Document
                        // object
                        if (!file.equals("")) {
                             client.document.archiveDoc(file, intFileID);
                   } catch (Exception e) {
                        System.err.println("File input error");
              } else
                   System.out.println("Error: Invalid Input");
    Org_A_Doc_Interface.java
    package project4;
    /* This class is the Standard Organization A Document Interface.
    * It defines various methods that any XML document object
    * in Organization A should understand
    public interface Org_A_Doc_Interface {
         void archiveDoc(String XMLSourceDoc, int fileID);
         String getDoc(int fileID);
         String getDocDate(int fileID);
         void setDocDate(String date, int fileID);
         String[] getDocAuthors(int fileID);
         void setDocAuthor(String authorname, int position, int fileID);
    Org_B_FileAuthorMgr.java
    package project4;
    public class Org_B_FileAuthorMgr {
         // This function returns the list of file authors for the file that matches
         // the given fileID. For the purpose of the assignment we have not
         // provided any implementation
         public String[] getFileAuthors(String fileID) {
              // Since we do not have any implementation, we just return a
              // null String array of size 2
              return new String[2];
         // This function sets the authorname at a given position for the file that
         // matches the given fileID.
         // For the purpose of the assignment we have not provided any
         // implementation
         public void setFileAuthor(String authorname, int position, String fileID) {
    Org_B_FileDateMgr.java
    package project4;
    public class Org_B_FileDateMgr {
         // This function returns the creation date for the file that matches
         // the given fileID. For the puprposes of the assignment we have not
         // provided any implementation but only return a date string.
         String getFileDate(String fileID) {
              return "1st Nov 2007";
         // This function sets the creation datefor the file that
         // matches the given fileID.
         // For the puprposes of the assignment we have not provided any
         // implementation
         void setFileDate(String date, String fileID) {
    Org_B_FileIOMgr.java
    package project4;
    import java.io.*;
    public class Org_B_FileIOMgr {
         // This class variable stores the file location for all files
         private String fileLocation;
         // This function stores the given String of XMLTargetFile at the
         // fileLocation which is set using the setFileLocation method
         boolean storeFile(String XMLTargetFile, String fileID) {
              if (this.fileLocation != null) {
                   FileOutputStream out; // declare a file output object
                   PrintStream p; // declare a print stream object
                   try {
                        // Create a new file output stream
                        // connected to "myfile.txt"
                        out = new FileOutputStream(fileLocation);
                        // Connect print stream to the output stream
                        p = new PrintStream(out);
                        p.println(XMLTargetFile);
                        p.close();
                        System.out.println("MSG from Org_B_FileIOMgr: Target File Successfully Saved with ID " + fileID);
                   } catch (Exception e) {
                        System.err.println("Error writing to file");
                        return false;
                   return true;
              System.out.println("MSG from Org_B_FileIOMgr: Please set the File Location before storing a file");
              return false;
         // This function sets the fileLocation where the file will be stored for
         // archive
         void setFileLocation(String fileLocation) {
              this.fileLocation = fileLocation;
         // This function retreives the file that matches the given fileID and
         // returns its contents as a string
         // Only for the puprposes of the assignment we have not provided any
         // implementation
         String retrieveFile(String fileID) {
              return "This is the retreived file";
    }Also, we've been given the following two classes which I believe are used to help with the xml transformation using SAX (I've done alot of research regarding parsing XML using SAX/DOM so I understand how it works, but I'm really struggling with the integration...)
    FileDetailsProvider.java
    package project4;
    /* This is the FileDetailsProvider Class which implements the Singleton design pattern.
    The class can be used in the following manner:
         // Declare a object of the class type
            FileDetailsProvider fp;
            // Get the single instance of this class by calling the getInstance static method
            fp= FileDetailsProvider.getInstance();
            // Initialize the class with providing it the file name of our configuration XML file
              fp.loadConfigFile("C:\\assignment4\\XMLTransformerConfig.xml");
    import java.io.File;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    public class FileDetailsProvider {
         private InputHandler handler;
         private SAXParserFactory factory;
         private SAXParser saxParser;
         private final static FileDetailsProvider INSTANCE = new FileDetailsProvider();
         // Private constructor suppresses generation of a (public) default
         // constructor
         private FileDetailsProvider() {
              // Create the content handler
              handler = new InputHandler();
              // Use the default (non-validating) parser
              factory = SAXParserFactory.newInstance();
              // Validate the XML as it is parsed by the SAX Parser: only works
              // for dtd's
              factory.setValidating(true);
              try {
                   saxParser = factory.newSAXParser();
              } catch (Throwable t) {
                   t.printStackTrace();
                   System.exit(0);
         // This is the public static method that returns a single instance of the
         // class everytime it is invoked
         public static FileDetailsProvider getInstance() {
              return INSTANCE;
         // After instantiation this method needs to be called to load the XMLTransformer Configuration xml
         // file that includes the xsl file details needed
         // for our assignment
         public void loadConfigFile(String configFile) {
              try {
                   INSTANCE.saxParser.parse(new File(configFile), INSTANCE.handler);
              } catch (Throwable t) {
                   t.printStackTrace();
                   // Exceptions thrown if validation fails or file not found
                   System.out.println();
                   System.out.println("C:\\Documents and Settings\\Jig\\Desktop\\Project 4\\Project4\\Transform.xsl");
                   System.exit(0);
         // This method return the xsl file name
         public String getXslfileName() {
              return handler.getXslfileName();
         // This method returns the xsl file location
         public String getXslfileLocation() {
              return handler.getXslfileLocation();
    InputHandler.java
    package project4;
    /* This class is used by the FileDetailsProvider Class to read the XMLTranformerConfig xml
    * file using a SAX parser which is a event based parser
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.helpers.DefaultHandler;
    public class InputHandler extends DefaultHandler {
         private String xslfileName = "";
         private String xslfileLocation = "";
         int fileName = 0, fileLoc = 0, DTDUrl = 0;
         boolean endOfFile = false;
         public InputHandler() {
         // Start XML Document Event
         public void startDocument() throws SAXException {
              super.startDocument();
         // End XML Document Event
         public void endDocument() throws SAXException {
              super.endDocument();
              // display();
         public void display() {
              System.out.println(xslfileName);
              System.out.println(xslfileLocation);
         public void startElement(String uri, String localName, String qName,
                   Attributes attributes) throws SAXException {
              String eName = localName; // element name
              if ("".equals(eName))
                   eName = qName; // not namespace-aware
              if (eName.equals("File Name:")) {
                   fileName++;
              } else if (eName.equals("File Location:")) {
                   fileLoc++;
         public void endElement(String uri, String localName, String qName)
                   throws SAXException {
              String eName = localName; // element name
              if ("".equals(eName))
                   eName = qName; // not namespace-aware
         public void characters(char ch[], int start, int length)
                   throws SAXException {
              String str = new String(ch, start, length);
              // Getting the Transform File Location
              if (fileLoc == 1 && xslfileLocation.equals("C:\\Documents and Settings\\Jig\\Desktop\\Project 4\\Project4\\")) {
                   xslfileLocation = str;
              // Getting the Transform File Name
              if (fileName == 1 && xslfileName.equals("Transform.xsl")) {
                   xslfileName = str;
         public void processingInstruction(String target, String data)
                   throws SAXException {
         // treat validation errors as fatal
         public void error(SAXParseException e) throws SAXParseException {
              throw e;
         // This method return the xsl file name
         public String getXslfileName() {
              return xslfileName;
         // This method returns the xsl file location
         public String getXslfileLocation() {
              return xslfileLocation;
    }I need to do the following:
    1. Create an adapter class and a facade class that allows Client A through the use of Organization's A interface to to use Organization B's services.
    2. Validate the Source XML against its DTD
    3. Extract information regarding the XSL file from the given XMLTransformerConfig xml file
    4. Apply the XSL Transformation to the source XML file to produce the target XML
    5. Validate the Target XML against its DTD
    Now I'm not asking for a free handout with this program completed as I really want to learn how to do a program like this, but I really don't have ANY prior java experience other than creating basic classes and methods. I don't know how to bring the whole program together in order to make it all work, so any guidance for making this work would be greatly appreciated.
    I've researched over 100 links on the web and found alot of useful information on adapter patterns with java and facade patterns, as well as SAX/DOM examples for parsing xml documents and validation of the DTD, but I can't find anything that ties this all together. Your help will be saving my grade...I hope :). Thanks so much for reading this.

    No one has anything to add for working on this project? I could really use some help, especially for creating the code for the adapter/facade pattern classes.

  • How to attach java program with CRM OD

    Hi
    i have a java program that i want to attach with CRM OD user interface so that i can run it on the press of a button or through any other way. Please suggest me some way to do this.

    Hi,
    The web applet and web tabs features allow you to embed content within CRM On Demand. You can develop an interface to your code (i.e. HTML page containing a button that will invoke your java application) which can appear within the CRMOD UI using these features.
    Thanks,
    Sean

  • Can't run java program with GUI

    My computer can run java program properly.
    However, for those program with GUI (using swing),
    my computer is unable to display the GUI.
    What's wrong with it? Is there any PATH I need to set before running GUI program?
    Thanks
    icedgold

    Cut, copy, paste then compile and run this;-import java.awt.*;
    import javax.swing.*;
    public class MyJFrame extends JFrame {
      public MyJFrame() {
          super("My first JFrame");
          Container c  = getContentPane();
          JPanel panel = new JPanel();
          panel.setBackground(Color.white);//  (new Color(255, 255, 255));
          JLabel jl = new JLabel("Yes it works");
          panel.add(jl);     
          c.add(panel);
      public static void main(String[] args) {
        MyJFrame frame = new MyJFrame();
        frame.setSize(180,120);
        frame.setLocation(200, 300);
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.setVisible(true);
    }

  • Why can't I run my Java program with just the JRE, the JDK is required?

    I've recently written 3 programs in Java using the Netbeans IDE with JDK 1.6 as the default Java platform. The compile-time libraries include the Swing Application Framework. I use BuildDesk from ProductiveMe to package the each program into a Windows installer.
    When I install the programs on a new computer without a JRE or JDK being present, and attempt to run them I get an error (as expected) stating that there is no JVM. The messages says that I need to install JDK 1.3 or higher. I downloaded the latest JRE onto the new computer and attempted to run the programs and I get the same error message. My question is, why can't I run these programs with just the JRE installed? Why do I need the JDK? When I install the JDK, the programs run fine. The typical user may not have the JDK on their system, but they likely have the JRE if they've run Java programs before.
    Is the answer as simple as there must be library functions being used by the programs that belong to the JDK, but not the JRE? I'd rather a user not have to install the JDK verses the JRE because they may also have to update some Windows environment variables.
    Thank you for any help on this issue.

    915088 wrote:
    Thanks for your replies. I further investigated BuildDesk and found an option which allows a JVM check but that check needs the JDK. I stopped the JVM check and rebuilt using BuildDesk and it now only requires the JRE to run the programs. The reason why I use BuildDesk is to package more than just the jar file for the user. BuildDesk allows me to create a installation folder structure as well as include any other files in the build. I could just as well zipped all this together for the user but decided against that method.I don't think anyone will question your usage of an installer tool; that is entirely up to you. But what is questionable is that you have problems with that installer tool and then go look for help in a Java programming forum. The next time, go look for help at the source. If there is no way to acquire help (support, a forum, a mailinglist, anything) then that is a very good reason to not use the product in question.

  • Running java program with arguments in Unix

    Hi
    I am a new newbie to java so pardon if this is too simple for you .
    This is my scenario. I have a java program which parses an xml and writes a .dat file. I execute this testparser.java in unix environment like this
    java testparser xml1.xml
    and it retuns me a .dat file
    But my issue is I have to run my parser program for 40 xml files. The requirement is I have to create a script file and possibly with a for loop which will loop through 1-40 xml files and return me the .dat file.
    I am really at a loss here. I am new both to Java and Unix
    So pls help me out
    Thanks in Advance
    G

    You could just do this in Java. Make it take all 40 xml files on the command line, and convert them all with one program invocation.
    If you want to do it in shell script, you can do something like
    for tmp in `ls -1 *.xml`; do
      java testparser $tmp
    donedepending on your shell, etc.

  • Help Me! How to send sms from a java program with a pda connected to system

    help me ,
    I am new in JavaME. I have to send sms from a java program, A PDA is connect to the system. Can some one help me to make that program which interact with PDA connected to system and send sms to any mobile or pda phones.

    user12873853 wrote:
    I believe JavaMail API will help in sending the mails and SMS through SMTP server. Sounds more like false hope than belief to me. The only way that would work is if you have an SMS gateway that allows communication through SMTP. Doubtlessly some exist (searching for 'JavaMail sms' through google certainly seems to indicate this), but if you have to ask you don't have one.
    And that exactly where you are stuck: to send SMS messages you need an SMS gateway. That will be the first thing you have to shop for, until then there is no reason to think about code, protocols or implementations. It can be as simple as hooking up a mobile phone, but then you cannot send bulk messages of course. Most likely you'll need to shop around for a partner that has an SMS blasting service you can use.

  • How do you start a java program with more RAM alloaction

    Hi
    can anyone please tell me how to start a java program to start with lots of RAM (RAM size is sent as a parameter), I have seen it somewhere and now I cant remember it. I have a server application to run this way.
    thanks and rgds
    sunil

    see the tooldocs of java: http://java.sun.com/j2se/1.4/docs/tooldocs/tools.html

  • ASP code to start a Java program (with parameters)

    Hi! All,
    I am trying to write some ASP code which should start a java program. Does anybody know a simple way to do this? Am new to ASP
    Thanks

    It doesn't have anything to do with java.
    Basically you need to make a system call which will start an external application. The external application can be anything including something like "java MyClass".
    So either find an ASP forum/board/newsgroup to ask how to do a system call or read some docs on it.

  • Running a java program with eclipse

    Hi,
    I'm trying to run this java program(below) in eclipse..when i go to the 'run' icon inorder to choose the option 'run as' then 'java application' , i have 'none applicable' as the only option available. is it possibly because the program uses threads?
    could someone using eclipse please try to execute this program and let me know if you succeed and how exactly you do it.
    package reseaux;
    import java.io.*;
    import java.net.*;
    import java.util.*;
         public class LeServeur extends Thread{
         Socket socket;
         BufferedReader in;
         PrintWriter out;
         Vector FlowList=new Vector(10);
         public LeServeur(Socket socket)throws IOException{
              this.socket=socket;
              in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
              out= new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
         public void run(){
              String s;
              synchronized(FlowList){
                   FlowList.addElement(this);
              try{
                   while(!(s = in.readLine()).equalsIgnoreCase("/quit")){
                        for(int i=0;i<FlowList.size();i++){
                             synchronized(FlowList){
                                  LeServeur monServeur=(LeServeur)FlowList.elementAt(i);
                                  monServeur.out.println(s + "\r");
                                  monServeur.out.flush();
              catch(IOException e){
                   e.printStackTrace();
         finally {
         try {
              in.close();
              out.close();
              socket.close();
         } catch(IOException ioe) {
         } finally {
              synchronized(FlowList) {
              FlowList.removeElement(this);
    thanks

    thanks...
    Infact, i wanted to run the main program called 'Serveur' but it uses 'LeServeur'( the code i sent before') and apparently it gives me an error msg that it doesnot recognise the 'LeServeur'...that's why i was thinking that i should probably first compile the 'LeServeur' so that it can be recognised in the 'Serveur' program.
    here is the 'Serveur' code that uses an instantiation of the LeServeur...
    package reseaux;
    import java.net.*;
    import java.io.*;
    public class Serveur {
              public int port;
              public ServerSocket skt;
              public Socket socket;
         public static void main(String[] args) {
              int port=8975;
              ServerSocket skt=null;
              Socket socket=null;
              try{
                   if(args.length>0)
                        port=Integer.parseInt(args[0]);
              catch(NumberFormatException n){
                   System.out.println("This port is used uniquely for listening");
                   System.exit(0);
              try{
                   skt= new ServerSocket(port);
              while (true){
                   socket =skt.accept();
                   LeServeur flow=new LeServeur();
                   flow.start();
         catch(IOException e){
              e.printStackTrace();
         finally{
              try{
                   skt.close();
              catch(IOException e){
                   e.printStackTrace();
    do you know have any idea why it doesnt recognise the 'LeServeur'?
    ps:they're in the same package
    thanks

  • Connecting a Local Java Program with a Mysql Database Hosted on the Interne

    I need help. I want to connect a java program running on local user computers to read and write to a mysql database hosted in my domain by an internet service provider.
    What code do i use?
    How do i connect?

    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html
    You'll ned to downloda the JDBC driver file from MySQL, and check their docs for the format of the connection URL.

Maybe you are looking for