Anything Java...

Does anyone have any experience installing the javax.crypto framework? Just curious. I have installed it locally (for single user) but don't really know how to install it system-wide.

Wish I could help but that's more than I could do! :)

Anyhow, since last time...I started a second project('cause the first is basically done) which requires me to keep the focus in a NSTextField after having pressed return(which fires an action).

I've tried everything I can think of..any ideas?

[Edited by IamBob on 12-08-2000 at 11:17 PM]
 
Anyhow, since last time...I started a second project('cause the first is basically done) which requires me to keep the focus in a NSTextField after having pressed return(which fires an action).

Are you pressing the enter key in a NSTextField in order to fire an action? One thing you might try in your action is something like the following:

public void testStayInNSTextField(NSTextField sender) {
//Do some code, whatever your action should do
sender.selectText(sender);
}

This should select all the text in the NSTextField and maintain focus on the NSTextField that sent the action...

Hope this helps... Also, make sure in the IB you set the "Only on Enter" in the Attributes Tab of the Inspector...
 
in the other thread we were trying to get an InputStream(and err) and OutputStream connected to a separate process...right? As I recall we never managed to get the outputstream connected/working and we just dropped it in favor of one-time calls.

Well, I figured it out finally...


class ShellAccess {

Process whatever;

public BufferedWriter doCommand(String cmd) throws IOException {

Runtime r = Runtime.getRuntime();
Process p = r.exec(cmd);

set(p); //connect our handle.

System.setIn(p.getInputStream());
//you can 'grab' the error stream too
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));

return out;
}

//so we can get a handle on the Process object to destroy() it later
public void set(Process p) { whatever = p; }
public Process get() { return whatever; }

}

//in a separate thread we can monitor System.in like so:
public void run() {
try {
while (true) {
if (System.in.available() != 0) {
byte[] b = new byte[System.in.available()];
System.in.read(b, 0, System.in.available());
String s = new String(b).trim();
//do something with "s".
}
}
} catch (Exception ex) {/*do something meaningful*/ }
}

so to use you'd do something like..

ShellAccess access = new ShellAccess();
BufferedWriter myout = access.doCommand("thecommand");
Process ourprocess = access.get();
if (myout != null) {
//it worked.
out.write("something");
out.flush();
out.close();
ourprocess.destroy();
}

..all in a try { } catch() of course.

I tried several similar ways of doing it but only that way worked. Hope it helps :)
 
I have an NSTextView that leaks like crazy. I'm not sure if it's my fault or not so here's some code I used:

NSTextView view; //the outlet from IB.

MyConstructor() {
view.setContinuousSpellCheckingEnabled(false); //not needed
view.setUsesRuler(false); //again, not needed
view.setRichText(true);
view.setUsesFontPanel(true); //probably not needed in the end.
}

//my method for inserting text
public void appendText(String text) {
view.insertText(text);
}


here's some of the errors:
*** _NSAutoreleaseNoPool(): Object 0x8127f0 of class NSCFDictionary autoreleased with no pool in place - just leaking
*** _NSAutoreleaseNoPool(): Object 0x811be0 of class NSCFString autoreleased with no pool in place - just leaking
*** _NSAutoreleaseNoPool(): Object 0x813410 of class NSConcreteValue autoreleased with no pool in place - just leaking
*** _NSAutoreleaseNoPool(): Object 0x811b60 of class NSCFDictionary autoreleased with no pool in place - just leaking
*** _NSAutoreleaseNoPool(): Object 0x815230 of class NSCFString autoreleased with no pool in place - just leaking

I wasn't able to edit it(insertText() didn't work) unless it was editable(go figure). I left it editable but in the end I need it selectable only. I'm not sure how I should go about appending text so any pointers would be great. It's probably another stupid thing I overlooked or don't get yet.

a 20 minute run and it's consumed 18% of the memory...this is not good.

well..thanks in advance.
 
Mm, looks like it should work bob, i'll try to use it later.

Sorry that i haven't been participating lately. I'm just so busy, i really wish i could spend more time on all of this.
Furthermore i still have problems compiling any code.
Even the example from the javatutorial.
I keep getting this error:
Code:
/usr/bin/jam -d1 JAMFILE=- build ACTION=build TARGETNAME=TemperatureConverter CPP_HEADERMAP_FILE=/Users/thedj/Documents/TemperatureConverter/build/intermediates/TemperatureConverter.build/Headermaps/TemperatureConverter.hmap DSTROOT=/ OBJROOT=/Users/thedj/Documents/TemperatureConverter/build/intermediates SRCROOT=/Users/thedj/Documents/TemperatureConverter SYMROOT=/Users/thedj/Documents/TemperatureConverter/build
warning: <TemperatureConverter>TemperatureConverter.app depends on itself
...found 29 target(s)...
...updating 10 target(s)...
BuildPhase TemperatureConverter.app 
Completed phase <CopyHeaders> for TemperatureConverter.app
Cp /Users/thedj/Documents/TemperatureConverter/build/TemperatureConverter.app/Contents/Info.plist 
BuildPhase TemperatureConverter.app 
Completed phase <CopyResources> for TemperatureConverter.app
CompileC /Users/thedj/Documents/TemperatureConverter/build/intermediates/TemperatureConverter.build/Objects/main.o 
/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6: header file 'objc/objc.h' not found
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:12: header file 'stdarg.h' not found
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:165: undefined type, found `va_list'
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:377: undefined type, found `va_list'
/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:33: header file 'stdarg.h' not found
/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:34: header file 'assert.h' not found
/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:35: header file 'ctype.h' not found
etc, etc, etc.

I can't find any of the frameworks it seems.
But they are there, they installed just fine.
I'm totally new at this, i only know java, so could someone tell me what the heck this means?

DJ
 
I have almost finished my installer package for Samba.
It's actualy quite easy to do.
All that is left are the scripts which NEED to be executed.
I know it can be done, but i cannot get it working.
Anyone out there who has succesfully used post_install scripts with such an installer?

DJ
 
I guess it means you broke Project Builder...

You just followed the JavaTutorial, right? I did the first part of the tutorial and even that didn't quite work right...but it sounds like something went psycho on you.

Try doing a new one...
you could just add a single NSTextField, make it send an action(on enter) and just println() the value.

I've got a couple PB/IB examples if you've got an installer script example! :D

[Edited by IamBob on 12-12-2000 at 05:13 PM]
 
Originally posted by The DJ

Furthermore i still have problems compiling any code.
Even the example from the javatutorial.
I keep getting this error:

Try deleting the build folder and rebuilding from scratch. Sometimes it loses track of what's there.
 
Originally posted by IamBob
I've got a couple PB/IB examples if you've got an installer script example!

Building packages is actually really simple.
The problem is if you have to add lines to files for instance.
Samba needs to open some ports and define services.
And those are all lines that need to be appended to files. And if there is a Sambaserver running already, it needs to take it down. I have seen it work (iTools uses them and the Developer package too) but for some reason it is not working.

How to build your own package:
1: put all you need to install in one directory : approot (or something like that.)
2: now create a License.rtf and the scripts if necesarry and put them in a directory: appresources.
3: open the PackageMaker from your Developer tools
4: Packageroot directory -> set to -> approot
5: Packageresources dir. -> set to -> appresources
6: All the other stuff is up to you.
7: Default location.
In case of an application with no other files in other dirs this would be /Applications. (This doesn\'t seem to work (I use / because i install in /Library and /usr. This is not the way i am supposed to do it. I should create a multiple part package.)
8: Set the flags
Needs Authorization: needs to be installed by admin user
Relocatable: Lets the user install at a different location then "Default" location (not working yet.)
9: Click create package and give it a name.
The names used for the scripts should be similar to the one you give here, if i'm correct

You can take a look at my experimental package (not functional yet) here:
http://home.student.utwente.nl/d.hartman/watdoeik/SambaInstaller.tar.gz

http://home.student.utwente.nl/d.hartman/watdoeik/NicerInstaller.tar.gz is there too and that one is working!!!!. piece of cake ;-) and enjoy


About point two.
I'm afraid i have to reinstall. We will see.

[Edited by The DJ on 12-12-2000 at 06:14 PM]
 
Sounds easy enough...I'll have to try it out sometime when I actually need to. :)

Well, after searching for hours I finally found something on my NSTextView problem. It seems there's a (known?) problem with the NSScrollView/NSTextView combo in IB.

It looks like I'm going to have to try picking apart the TextEdit example(../Developer/Examples/Java/AppKit/TextEdit/) to get something working.
 
I figured out why i can't compile. All the necesarry files are there. That's why a reinstallation of the tools doesn't change a thing.
cc (which is called on by Projectbuilder) seems to have lost the path to my frameworks.
Now to get them back. And that's the real problem. I don't know a thing about the compiler let alone how it works in OSX. Maybe if i can find the config file, then ik can delete it and reinstall the tools. (Or ask one of you guys to copy it for me.

BTW. found out that my sambapackage uses "find -maxdepth" to upload directories. And -maxdepth is not in the BSD version of find. So i was trying to compile the GNU findutils and found out that cc wasn't working either. I really need this hard at the moment, so if someone is interested in compiling it for me, you can find it here:
ftp://labrea.stanford.edu/pub/gnu/findutils/findutils-4.1.tar.gz
 
I saw that..that's why I added in the "when I actually need to" bit.

Well, now I guess I can try making an installer package myself. I just updated Nicer a bit(more optimizations, fixed the drawer size, etc).

Any luck with fixing cc?
 
Originally posted by IamBob
I saw that..that's why I added in the "when I actually need to" bit.
Well, now I guess I can try making an installer package myself. I just updated Nicer a bit(more optimizations, fixed the drawer size, etc).
Any luck with fixing cc?

Whoops, sort of a double post.
And no no luck.
Guess i have to reinstall from the ground up if i want this fixed. Prob is i have a lot of stuff on the disk that will need backing up. And my 4 weeks old burner simply stopped functioning, so lack a bit of storage options.

DJ
 
That sucks. If there's anything I can do let me know. :)

Well, I updated Nicer. Source is included now. I sort of decided against the installer package thing. It's too simple of an app to need one(besides, when I tried to make one I managed to include half my HD ;) ).

see ya
 
Well, to finally figure out why my newest project leaked I started a new one. In this new project I went ahead and did a scaled-down version of what I need. After several hours of toying with it I decided to scrap the separate Thread I was using.

I had:
Code:
class Test implements Runnable /*-or- extends Thread*/ {
  ClassWithNSTextViewHandle handle;
  Thread thisThread;
final String t1 = "hello world! \n";
final String t2 = "this is the second string. \n";
final String t3 = "okay, we're done. \n\n\n        bye!";

public Test(ClassWithNSTextViewHandle handle) {
    this.handle = handle;
    
     thisThread = new Thread(Test.this);
       thisThread.setDaemon(true); //or not. either way.
       thisThread.start();
 }

public void run() {
    int cnt = 0;
       while (true) {
          cnt++;
         switch(c) {
             case 1:
                handle.appendText(t1);
                continue; //sends us on to the next iteration of the loop.
             case 2:
                handle.appendText(t1);
                continue;
             case 3:
                handle.appendText(t1);
                continue;
         default:
           break; 
        }
     break;  //exits the while() loop.
     }
   System.out.println("Test.run() is done.");
  }
}

 class ClassWithNSTextViewHandle {
   NSTextView nstextview;  //IB Outlet

public void appendText(String txt) {
      if (txt == null || nstextview == null) return;
    NSRange range = new NSRange(nstextview.string().length(),0);
if (nstextview.shouldChangeTextInRange(range, txt)) {
    nstextview.textStorage().beginEditing();
    nstextview.textStorage().replaceCharactersInRange(range, txt);
    nstextview.textStorage().endEditing();
    nstextview.didChangeText();
  }
 }
}
after trying every variation of that(setDaemon(false), extends Thread, etc) I went ahead and commented out everything that made it its own Thread...

...and it worked!! :mad: :confused:

So, I sent Apple a bug report with the source that worked and the source that didn't. Too bad I really need that thread in my app. If someone wants to waste some time... :)

well, see ya.

[Edited by IamBob on 12-19-2000 at 08:30 PM]
 
Originally posted by IamBob
Well, to finally figure out why my newest project leaked I started a new one. In this new project I went ahead and did a scaled-down version of what I need. After several hours of toying with it I decided to scrap the separate Thread I was using.

He there again. Long time no seen. Haven't been around for a while. I had a lot of stuff on my hands. (Again exams and my dorm's Christmas dinner which i had to organize)
I'm staying with my parents during the holidays, so i wont be able to work on any stuff untill after new year.

Good to see you figured out the problem. I still have to reinstall the entire system, but i found out that my bug with uploading dirs in Samba was a problem with find. The darwin developers told me they were going to fix it and i have an alternative untill final. In the meanwhile i managed to fry up my keyboard. So i will have to get one of those new Apple USB kb. ;-)

Well, merry christmas to ya all, and a happy new year.

DJ
 
yeah, merry christmas and a happy new year!

I've been kind of busy trying every possible workaround. Seems you can get around the leak by using an NSAutoReleasePool(I think). Now it only leaks twice at start and once at quit...so it's not too bad. I still would like to squish all the leaks though. I'll get it eventually.

Well, back to coding, I think. :)
 
Bob,
If you were using ObjC, I believe the solution to your leak might lie in,
Code:
[NSApplication detachDrawingThread:toTarget:withObject:]
I poked around in NSApplication with Java Browser, but couldn\\\'t find a similar method. I\\\'m about ready to give up on Java/Cocoa myself. It sure seems to be the poor 2nd cousin to ObjC/Cocoa.

BTW: I\'m the one who mailed you today about my changes to Nicer.

Terry
 
Back
Top