open, read, ioctl calls in java?
I am working on a java wrapper for a linux library that uses files to open(), read(), and issue ioctl() calls to a device. I assume I can open() and read() the device file as I would any standard file in java. Is this correct? What about the ioctl() calls? Can I do these in java wthout using JNI? If I use jni, I have seen references that certain system calls (open(), read(), etc.) cannot be used in the native code, due to green thread issues. Is this still the case? Is there anyway I will be able to make the ioctl calls? Ideally, I'll open(), read() and close() the file from java, but how will I do the ioctl()? Thanks for any suggestions, -- Kevin White, Software Engineer Envision Telephony [EMAIL PROTECTED] [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
examples of creating a new object in jni?
I am having a tough time piecing together the (lack of) documentation on using native code to actually allocate (and call the constructor of) a new object. Can someone please point me to an example? I have a java class that needs to be constructed by some native code. It will take 4 parameters in the constructor, so I'd like to see a sample with multiple paramters. I've been reading the JNI tutorial at sun, but they don't have an example of this, and I've been looking through the actual JNI spec but of course, that's like reading a dictionary to try to learn grammar... Any pointers or suggestions are helpful and appreciated. -- Kevin White, Software Engineer Envision Telephony [EMAIL PROTECTED] [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
null layout?
I have a frame in which I would like to use no layout manager so that I can directly position elements where I want them. I use the following code, in the constructor of a class that descends from Frame: setSize(600,380); setLayout(null); Label label=new Label("Hi there"); label.setBounds(10,10,200,20); add(label); Is there anything wrong with this? This is what I do on other platforms and works fine. However, unless I use a layout manager, I cannot see this label show up on the window. -- Kevin White, Software Engineer Envision Telephony [EMAIL PROTECTED] [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
It's finished!
Well, the code anyway. I have now finished the first version of a java class wrapper for the linux joystick driver, written a java gui test program, and it works! ... er, At least it works on my system, with my jdk, on my distribution, with my joystick, so I'd like to make it available for others to test. But, as this is my first linux programming project, I have no clue how to build appropriate makefile for: 1- gotta build the native .c file into a shared library 2- build the java files into a jar 3- need to install the .so created in step 1 into an appropriate directory. (In the LD_LIBRARY_PATH?) 4- put the .jar file in an appropriate directory in the classpath. 5- How do I put an appropriate "license" on it so it can be used freely? I'd like changes to come back to me, so I can be the maintainer of the thing, but want people to use or improve it, and make it useful. So,I think there should be: make clean make configure - do I need this? maybe to find out where the linux jni includes are? make - to build the so, and the jar files make install - to install the stuff appropriately Should I write the doc in javadoc since it's just a set of classes for an api? Or in a readme? Both? Where do I include the license descriptions? Is there a "template" or sample license file somewhere that I can use? I appreciate any help in this, since I've never attempted this stuff, and have never done makefiles, shell scripts, etc. Where do I start? Thanks, -- Kevin White, Software Engineer Envision Telephony [EMAIL PROTECTED] [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
My big stupid mistake
Ok, I'm really stupid. Please don't flame me for how stupid I was. I was writing a Makefile and testing it. In the make file I have: #make a directory we can use for jarring things up mkdir jar #copy the com/kevinsworld/. directory structure cp -r com jar cd jar #don't want java files in the jar, just class files rm com/kevinsworld/linux/devices/*.java #create the jar jar -c0vf com cd .. rm -r jar First problem: the cd apparently doesn't work in the make file, so it actually removed my java source files from where I really, _really_ didn't want them removed. Oh, where is linux's undelete feature! (You know, the "gotta protect the morons" feature...). So, how do I "cd" in a makefile? Jar only works correctly if you're in the directory of what you want to jar. i.e.: if I am in jar and say "jar -c0vf jar/com" it puts the files in the jar as if they were in package jar/com/kevinsworld/... rather than com/kevinsworld/... So, how do I cd in a makefile? Second problem. I was stupid and didn't think to copy my source files elsewhere. This is a relatively small project I was just working on and hadn't backed up yet. (I already admitted to stupidity). Can I disassemble my java .class files to get something to work from to recreate the source? Thanks for any help, The Moron -- Kevin White, Software Engineer Envision Telephony [EMAIL PROTECTED] [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: My big stupid mistake - Thanks!
Thanks to all the pointers. I decided to get jad as the decompiler to use, and it worked great. I still have to test all the class files after compiling them from what it creates, but going through the source, jad sure did a good job. Also thanks for the pointers on the Makefile problems I had. Kevin White [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Thanks everyone
Thanks to everyone's help the last several days on jni programming with linux, help with Makefile suggestions, and even helping me with stupid errors, I was able to get my first linux project released (development release, of course). Just thought I'd thank everyone on this list for their help. If you're interested, it's a java wrapper over the linux joystick driver. It's available through www.kevinsworld.com. Thanks again! -- Kevin White, Software Engineer Envision Telephony [EMAIL PROTECTED] [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: JNI - gcc compiler options
Shoban Jeyaraj wrote: > I am new to Linux, and recently, our company has decided to do some projects > on Linux using Java. The project involves JNI. I'd like to know how I should > go about creating the shared libraries that Java is going to interface with. > > I have created the header files using javah. I have also implemented those > function declarations on a .c file. I'd like to know a sample 'cc' command > with the switches to compile the .c file to produce a shared library that > could be used by Java. > I have written a very simple JNI program with a very simple Makefile that you can take a look at. It is not very feature rich with compiler options other than basic compilation and creating the shared library. You can download it from www.kevinsworld.com, it's the JavaJoystick api. Hope it helps, -- Kevin White, Software Engineer Envision Telephony [EMAIL PROTECTED] [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]