Solved

Java parallel port control

Posted on 2014-02-13
5
998 Views
Last Modified: 2014-02-16
I need to set and reset a bit on the parallel port of my computer.  I have been browsing the web but can't seem to come up with anything.  I would like a piece of code that would accomplish that.  Thanks!
0
Comment
Question by:sargent240
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 39857918
Unfortunately, this can't be done with *just* a piece of code. Java doesn't support such low-level hardware access as it would be completly dependant on the underlying OS.

However, there seems to be libraries around that (via JNI) can provide that access. I don't have any first hand experience but if you are using Windows, this one looks to be the most promising...

Jnpout32
http://www.hytherion.com/beattidp/comput/pport.htm
(Scroll down past the C/C++ section to find that part applicable to Java)

While I don't have any experience with it, if you do decide to try this and run into problems, post here and I still may be able to assist you further.
0
 

Author Comment

by:sargent240
ID: 39861501
If I write a routine using C could I call the routine from Java?
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39862141
If I write a routine using C could I call the routine from Java?
Yeah, for sure. If you are comfortable writing in C this would probably be the best. Have a look through a JNI tutorial such as this first...

http://www3.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html

It will give you the whole story about the JNI process, from writing the Java side interface class, using javah to generate the C headers, writing the C code and compiling to either a DLL for Windows or a .so for Linux.
0
 

Author Closing Comment

by:sargent240
ID: 39862807
Thanks, I've written a lot of C code.  That will work.
0
 
LVL 35

Expert Comment

by:mccarl
ID: 39863561
Cool, glad to help! :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now