Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

I/O through the LPT port.

Posted on 1998-02-21
3
Medium Priority
?
317 Views
Last Modified: 2012-06-27
I've bought a K8000 Kit from Velleman. That's an interface specific for domotica. That interface is connected to my computer through my LPT1 port. Is there somenone who knows how to handle parallel communication in Jave ?
0
Comment
Question by:ndb
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 1233178
Only through a native interface to the host operating system.  Java provides no built-in capabilities to access hardware directly.
0
 
LVL 2

Expert Comment

by:shogi
ID: 1233179
You can always do a open file on the LPTx you need, if it's for simple use. Otherwise you need to write C/C++ DLL to the host operating system, and access it with the JNI (java native interface).

Here an example for LPT1 :

public void printLTP1(String OutPrint)
{
  if (OutPrint != "")
  {
     PrintWriter out = null;
     try
     {
        out = new PrintWriter(new BufferedWriter(new FileWriter("lpt1")));
     }
     catch ( IOException e)
     {}
     out.print(OutPrint);
     out.flush();
     out.close();
}

0
 
LVL 2

Expert Comment

by:shogi
ID: 1233180
forgot one
}  // end of the method PrintLPT1


0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question