-
problem in java
hii to all
actually i am 2nd year enginnering student and working on the project in java.
i wannna know that how compact disk drive can be open or closed through java. ie just by clicking one button cd drive should open and a required cd may be put inside and then on clicking the other button it should go inside.
can u give me the source code or any link to it.
thnxx in advance.
-
-
hi sirdice
i had gon through that link but there was writen that it is not possible through java api . but there was written this:---------
"As you suggest, you will need to call an ioctl in the device driver using JNI.
Or, if your OS has a "cdeject" command, you could call that instead. That
is the approach I would use. "
i duuno know about JNI so if practically is there any way to tackle it,,any sort of coding in java is possible regarding this.
thnxxxxxxxx in advance.
-
So you are trying to get a program to recognize if there is any medium in the CD drive?
The only way you could do that, that I could think of, is by interacting with the CD driver; I'm not too sure about how to do that with java. I'm pretty sure that there is some way to do that in C (then you could use JNI to put it into Java, or c2java).
There are several links of interest though:
Hardware interaction with Java
Part of the JINI Archives
Having UI with Hardware
Good luck, this is a hard problem.
-
If I read those google posts correctly the solution is highly platform dependant which kind of defeats the reason for using java (being platform independant et al)..
-
hey sir dice
iam in the of this project and i am still trying to figure it out how to get it done. is it really not possible to do that through java.plzzz try if you find one such link or any other information about it.
thnx in advance
-
Quote:
Originally posted here by shals
hey sir dice
iam in the of this project and i am still trying to figure it out how to get it done. is it really not possible to do that through java.plzzz try if you find one such link or any other information about it.
thnx in advance
For goodness sake, this is _your_ project...
Why don't you do the legwork to find the answer!
Steve
-
Well, what you are asking to do is very hardware oriented, and is thus platform dependent.
The only feasible way to do this, as an alternative, is to use native methods. I wouldn't know where to begin with that; alternatively, you could load C libraries that contain the methods, and just use them in java.
Again, it is platform dependent to manipulate the hardware in a way that you need. There's no way around that.
-
hey arki
yes this is hardware dependent then also is there a code whuch can be applied to one computer only.
-
I assume you mean by "applied to one computer only" as applying your code to some test computer?
Well, I am no engineer (first of all), so I would be assuming that for your project you would want to try to mimic the "open/cose cd drive" command that is given when you push the button. I have no clue how you would do this.
I think, honestly, the best bet would be to use servlets; though I should confess I have no experience with servlets so I don't know their limitations. But it seems feasible that with a servlet you could program one such that if you click a button on some gui, it should send a signal to open the cd rom.
I did find detecting CDs with Java, an article in the Linux Gazette, though I would recommend that you look into the JNI.
[edit] A thought, why don't you make a program in java that: uses JNI, and then writes a C++ program that implements the Java method. It would theoretically, as far as I know, be platform "independent" -- provided that the C++ compiler 1. exists on the computer, and 2. is known.
-
Arkimedes edited answer sounds like a good solution to me. I would warn you though, looking into and using Java Native Interface (JNI) is not easy. It's nothing like pure Java, or so i have read.
-
I had just played around with loading libraries in java, and I think now the best way to do what you'd like is to make a dll that does what you want with the CD rom; load it via System.loadlibrary("MyLibrary"), and create a public native void openCD(); method in your class.
It works for writing to the bootsector of a floppy disk ;)