# Anything Java...



## IamBob (Nov 29, 2000)

Anything Java...
questions, comments, source, project ideas and in-the-works projects are welcome and encouraged.

Here's my not yet completed project and ProjectBuilder example. -being updated tomorrow.

[Edited by IamBob on 11-29-2000 at 01:37 PM]


----------



## G4Rules (Nov 30, 2000)

IAmBob -

This kind of comes from the other thread, about documentation and such with the java classes or more specifically, the NS classes. I assume since you have the PB/IB you have the Developer Tools... If so, have you seen the application called 'JavaBrowser' ? That is a really nice tool that shows all the classes, constructors, methods, fields, etc... 

It seems to be the only fairly complete documentation of the classes... You'll notice 3 buttons at the bottom of the window... the one that looks like 'books' has descriptions of the methods and such.

Is that something that might help?


----------



## The DJ (Nov 30, 2000)

> _Originally posted by G4Rules _
> *IAmBob -
> If so, have you seen the application called 'JavaBrowser' ? That is a really nice tool that shows all the classes, constructors, methods, fields, etc...
> *



Cool i'll check that one out too.
I have also found this on Apple's http://developer.apple.com/techpubs/macosx/Cocoa/Reference/ApplicationKit/Java/Classes/

The directory contains websites with information on all Cocoa-Java classes. Not really nice, but useable. It has info on the in's and out's of the classes. The variables and the methods it contains etc.

Hopefully i can start working on cocoafy'ing my app the coming weekend. Let's make this Thread a place too share our experiences doing just that.
If you ask me the Java + Cocoa way simply rocks.

DJ


----------



## The DJ (Nov 30, 2000)

As IamBob mentioned.
This is the place for all the people who would like to build Java/Cocoa applications(GUI's) over all those nice Command Line Utilities.
You can find my project here:
http://home.student.utwente.nl/d.hartman/watdoeik/gui.html

It is an attempt to create a GUI for the SAMBA package. (Of which the OSX version is my work aswell by the way   )

DJ


----------



## The DJ (Nov 30, 2000)

Is there anyone around who has created Packages and scripts for the OSX Installer?
I would like to take a shot at it myself, but it would be nice if i knew there was someone there who could help me out with any questions or problems i will run into.

DJ


----------



## The DJ (Nov 30, 2000)

> MySQL 3.23.28 Double-clickable Installer Package
> I have built MySQL 3.23.28 and rolled it into an Installer package. It's available at http://www-u.life.uiuc.edu/~mwvaugh/MacOSX/Packages/
> 
> Cheers,
> Matt



Found this thread on the subject. This will probably get me started.

DJ


----------



## IamBob (Nov 30, 2000)

hey..thanks! I have used JavaBrowser a bit(checking for the old MRJ stuff mostly) but didn't notice the books button.



> Not really nice, but useable.


you said it. I guess that's what I was trying to get at with my lil rant back in the other thread...sorry 'bout that.

I didn't even think about installer scripts or anything. Maybe I'll dabble and see if I can't get something working in that area as well.

Well, I'm gonna go update my page and check out the JavaBrowser and see if I can't get a simple NS project working

see ya.


----------



## IamBob (Nov 30, 2000)

> I downloaded Nicer and nothing happens when I double-click a process. I don't know what's wrong.



I didn't think about it untill now...

if you minimize it, switch apps then come back to it it locks you out. The "fix" is to switch apps again(while it's not minimized). I had reported that to Apple and forgot about it. I'm not having it do any voodoo when it recieves windowIconified or windowDeiconified events so I know it's not my code. I had tried a few things to workaround it but nothing seems to fix it. I don't know if that was what happened so whatever..I'm working on it.

Oh, the JavaBrowser rocks! I think I tried clicking the book button before(couple weeks ago when I was messing with it) and nothing happened..now I know why. I was probably trying to view source  it couldn't find(duh@myself). I went ahead and added the JDK docs to its list of searchable directories...that's damn cool. 

on another note..I've got a new project going. I'm trying to use NS classes for Nicer's GUI. I've got my table(NSTableView) in the window and a label at the bottom. I guess my problem is that I don't know how to get a handle to the table besides through the events it sends. I need to be able to populate the table and for now it only almost-kinda-works. When you click on one of the column headers it puts some junk data in the table(as it should for now). Obviously this won't work so I'm lost.

well, I still need to go update my page so I guess I'll do that.

[Edited by IamBob on 11-30-2000 at 05:06 PM]


----------



## tie (Dec 2, 2000)

> _Originally posted by IamBob _
> *I guess my problem is that I don't know how to get a handle to the table besides through the events it sends. I need to be able to populate the table*



I'm not a programmer, and know very little about Cocoa. But here is a bit of code that uses an OutlineView (subclass of TableView). I don't know how directly to get a handle to the table, either -- but if you use interface builder, then it should give you the handle automatically. 

To populate the table, you use the delegate methods. For an outline view, this is done in the outlineViewChildOfItem method (which gives an item (null if top-level) and the index of the child requested). Another delegate method is outlineViewObjectValueForItem, which gives you a table column and the item representing the row being displayed; you need to extract the column info from the item. 

That's probably unclear. I agree that the documentation is pretty awful, especially compared to that for Java. But the sample ObjC code is useful for understanding the API through Java as well. 

-- 
<pre>
/* ArticlesList */

import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;

import java.io.*;
import java.util.*;
import java.text.*;

public class ArticlesList {

  Vector threads = new Vector();	// initialize for outline view

  NSOutlineView outline;
  NSWindow articlesWindow;

  Client client;

  private void addArticle(Article art, Hashtable threads) {
    Vector refs = art.header.references;
    if (null != refs) {
      for (Enumeration e = refs.elements(); e.hasMoreElements(); ) {
        String ref = (String)e.nextElement();
        NSMutableArray thread = (NSMutableArray)threads.get(ref);	// make Thread
        if (thread != null) {
          thread.addObject(art);
          return;
        }
      }
    }
        // no thread has fit
    NSMutableArray thread = new NSMutableArray();
    thread.addObject(art);
    if (art.header.id != null) {
      threads.put(art.header.id, thread);
    } else {
      threads.put(art.header, thread);	// doesn't need to be in thread list
    }
  }

  public void loadArticles(Client client, Newsgroup group) {
    this.client = client;
    Hashtable threads = new Hashtable();
    try {
      client.selectGroup(group);
      for (int i = group.start; i <= group.end; i++) {
        String header = client.getHeader(i);
        if (null != header) {
          Article article = new Article(header);
          addArticle(article, threads);
        }
      }
    } catch (IOException e) {
      System.out.println("Error: lost connection");
      return;
    }
    this.threads = new Vector(threads.values());
    System.out.println("Fetched " + threads.size() + " threads");

    outline.reloadData();

    if (!articlesWindow.isVisible()) {
      articlesWindow.setFrame(new NSRect(183, 75, 556, 422), true);
    }
    articlesWindow.orderWindow(NSWindow.Above, 0);
    articlesWindow.makeKeyWindow();
  }

    // Returns the number of child items encompassed by item. If item is null, this method should return the number of children for the top-level item. 
    // only called on objects which are expandable (Vectors)
  public int outlineViewNumberOfChildrenOfItem(NSOutlineView outlineView, Object object) {
    if (null == object) {
      return threads.size();
    } else {
      return (((NSMutableArray)object).count() - 1);
    }
  }

    // Returns the data object associated with the specified item. The item is located in the specified tableColumn of the view
  public Object outlineViewObjectValueForItem(NSOutlineView outlineView, NSTableColumn tableColumn, Object item) {
    if (null == item) {
      return null;
    }
    Article article;
    //if ("java.util.Vector".equals(item.getClass().getName())) {
    if (item.getClass().getName().endsWith("NSMutableArray")) {
      article = (Article)((NSMutableArray)item).objectAtIndex(0);
      //return ("" + ((NSMutableArray)item).count());
    } else {
      article = (Article)item;
    }

    String response = null;
    if (tableColumn.identifier().equals("author")) {
      response = article.header.from.name;
    } else if (tableColumn.identifier().equals("subject")) {
      response = article.header.subject;
    } else if (tableColumn.identifier().equals("date")) {
      response = DateFormat.getDateInstance().format(article.header.date);
    }
    return response;
  }

    // This method should return true if item can be expanded to display its children. 
  public boolean outlineViewIsItemExpandable(NSOutlineView outlineView, Object item) {
    if (null == item) {
      return false;
    } else {
      //if ("java.util.Vector".equals(item.getClass().getName())) {
      if (item.getClass().getName().endsWith("NSMutableArray")) {
    //  Vector v = (Vector)item;
        NSMutableArray v = (NSMutableArray)item;
        return (v.count() > 1);
      } else {
        return false;
      }
    }
  }

    // Returns the child item at the specified index. Children of a given parent item are accessed sequentially. If item is null, this method should return the appropriate child item of the root object. 
  public Object outlineViewChildOfItem( NSOutlineView outlineView, int index, Object item) {
    if (null == item) {
      return threads.elementAt(index);
    } else if (item.getClass().getName().endsWith("NSMutableArray")) {
      NSMutableArray v = (NSMutableArray)item;
      return v.objectAtIndex(index + 1);
    } else return null;
  }
}

</pre>

One last thing: I wasn't able to use Vectors as the row representation item for some reason; that's why I'm using NSMutableArrays.

[Edited by tie on 12-02-2000 at 09:38 PM]


----------



## IamBob (Dec 3, 2000)

> I'm not a programmer, and know very little about Cocoa.



Well, I'm impressed. You've obviously have a better grasp on these things than I do. 

As for IB giving you a handle..not quite and not that easily. I'm going to sift my way through the docs and see if I can get around having to use IB(or how to better use it). I went through the Cocoa/IB/PB tutorial and still don't quite get it. If someone wants to do an example IB/PB project, please, do so.

Well, thanks for the ideas at least. I'm not sure what I'm going to do next...ahh!


----------



## Ghoser777 (Dec 3, 2000)

Okay, i tried to mull through this the hardway, but i think the coming finals week has prematurely fired my brain.  Thw NSBrowser docs made NO sense to me.  All I want is a nice little "Open" menu item that would allow the user to select a file in the file heiarchy.  WEll, I have the mneu item, and I even have a nice, but empty NSBrowser field.  So... what do i have to do to make it so all the hardrives and the like comes up as the first column and from which u can navigate down the file structure?  (That's a big question, but my brain is REALLY fried.)

Second, does anyone know how to make it so you can drap a file onto an window and the location of the file is then taken by the java app so it can do its little eveil deeds with the file?

Just a wonderin'
F-bacher


----------



## tie (Dec 3, 2000)

> _Originally posted by Ghoser777 _
> *All I want is a nice little "Open" menu item that would allow the user to select a file in the file heiarchy.
> 
> Second, does anyone know how to make it so you can drap a file onto an window and the location of the file is then taken*



Maybe you should look at NSOpenPanel instead of using an NSBrowser (but if you want to do it the hard way, there is an AppKit example which uses an OutlineView to browse through files).  For the second question, try looking at the drag-and-drop code, then NSPasteboard.  You use the drag pasteboard and take dataForType("FilenamesPboardType").  I believe Java now has drag-and-drop built in, too, but I have never tried it.


----------



## tie (Dec 4, 2000)

> _Originally posted by IamBob _
> As for IB giving you a handle..not quite and not that easily.[/B]



I'm not entirely sure what's holding you up here.  

Here's what I just tried: I opened P(roject)B(uilder) and created a new Cocoa project.  I opened the Main.nib file with I(nterface)B(uilder).  There already was a blank window; I just dragged into it a TableView (packaged inside a ScrollView on the top right of the tabulation views palette).  I opened the Inspector and double-clicked the table columns to set their names, "Date" and "Name."  In the Attribute panel I set their respective identifiers to be "Date and "Name" as well.  That's done.  

Next, I switched to the Classes tab, selected java.lang.Object and went to Classes/Subclass.  I named the subclass TableSource.  I then went to Classes/Add Outlet, and added an outlet called table.  Finally, I selected the class, and went to Classes/Instantiate.  

Back in the Instances tab, I control-dragged from the TableSource object into the TableView.  With the Inspector open, it switches to the Connections pane, and shows the single outlet, table.  Press connect and it should say that an NSTableView is connected.  I then control-dragged from the TableView to the TableSource.  I selected the dataSource outlet and connected that.  Finally, I went to the Classes tab, selected TableSource and went to Classes/Create Files...  Saved a java file and finished with IB.  

Now in PB, I opened the TableSource.java file and put in the following code (some was already there): 

<pre>
/* TableSource */

import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;

public class TableSource {

  NSTableView table;

  public int numberOfRowsInTableView(NSTableView aTableView) {
    return 100;
  }


  public Object tableViewObjectValueForLocation(NSTableView aTableView, NSTableColumn aTableColumn, int rowIndex) {
    if (aTableColumn.identifier().equals("Date")) {
      return ("Date" + rowIndex);
    } else {
      return ("Name" + rowIndex);
    }
  }
}
</pre>

Save the nib and compile, and you should have a working, scrolling table, with row n having "Daten", "Namen" in it.  It actually doesn't use the table outlet, but it is there if you need it (call table.reloadData() if the datasource changes).  This is what I meant when I said IB automatically gives you a handle; it does so if you create an outlet and connect it.  

[Edited by tie on 12-04-2000 at 12:26 AM]


----------



## IamBob (Dec 4, 2000)

And now I feel stupid because the IDE isn't doing what I want how I want. Every time I've tried to use an IDE it's been awkward and more of a pain than it's worth. This time is no exception.

I had something like that((../Developer/Documentation/Cocoa/JavaTutorial/)JavaTutorial.pdf led) but wasn't sure which connections to make and how to get a handle to the NSTableView without needing an action first.

I should be able to get it working now...thanks!


----------



## IamBob (Dec 4, 2000)

I get it! 

A week of awkwardness for this ease...not bad. Sure, it'll take me a bit to get fully used to it but this could almost be fun.

damn you rock! I'm gonna go see if I can get this really flyin'!


----------



## IamBob (Dec 4, 2000)

Got the ps data in the table and am recieving clicks. I'm able to get the data under the clicks. I've just got to add the slider, buttons and a label. That was too easy!

I guess it didn't quite click in my head. I owe you big time!


----------



## nullcc (Dec 4, 2000)

Ok, so here is what I have...
I have a little program that draws an immovable window in the bakcground of everything (everything but the desktop... still don't know about that) then makes a little NSView subclass that makes it snow in the background (there was a nifty app like that I liked when I Was messing with a little bit o redhat a while ago, but that system DIED hardcore [won't even start up anymore], so I am now scared of linux).

ANYWAY, I'm having the worst time trying to convince the the NSWindow to not redraw my view everytime... among other things, like transparency, and many other other things. I want to have control on what it re-draws, so that I can pile up snow, and stuff...
Everything I've tried (in messing with my  SnowView and with the NSWindow) still redraws the whole thing from scratch (particularly, it displays the NSWindow's background on the entire frame)

So, my other thought was to save that which I draw to a picture, and then I could have control in updating that, but all I can find is the NSCustomGraphicsContext, which also re-draws everytime...

I really just want a java-esc getGraphics() method that won't flush the image... 

forget what it's called though..
non-disposal, or something?

However, the app DOES run, mostly... 
Takes up a bit of CPU time, and I am not sure how to tell the OS that my process isn't very important (do I even need to do that?) even on my B+W G3

I might even post it someplace, because I've seen some cute useless things like it out there...

I'm just messing around, no real programming knowledge and it is still fun, so I am keeping at it...


still... some people keep saying that Java is slow, even as Cocoa, to do anything useful....

but I have hope...


cc


----------



## Ghoser777 (Dec 4, 2000)

> _Originally posted by nullcc _
> *However, the app DOES run, mostly...
> Takes up a bit of CPU time, and I am not sure how to tell the OS that my process isn't very important (do I even need to do that?) even on my B+W G3
> 
> ...



use "renice number app", where number is between -20 and 20, with -20 giving highest priority.

HTH,
F-bacher


----------



## IamBob (Dec 5, 2000)

> However, the app DOES run, mostly...
> Takes up a bit of CPU time, and I am not sure how to tell the OS that my process isn't very important (do I even need to do that?) even on my B+W G3



You don't have to but you might want to renice. You can find source to do that here. You'd need to call ps(look in the man for the best way) to get the PID of your process then as Ghoser777 said, "renice newval pid". As for your window problem, can't you unbuffer it in the IB>Inpector>Attributes of the window?


Okay, I'm lovin' it. Sure, the docs could be a little better but you almost don't need them..so it doesn't matter. After it clicked in my head I've had almost no trouble with IB. I had a few problems getting my drawer sized properly and it's still not quite right but it's ok...nothing major.

I think it's taken me about 3 hours to get it from all Java to Obj-C++(Apple's own term..look in Project BuilderWO>Inspector). And most of the time taken was just sizing and resizing components to get them how I wanted.

I need to go update my page...got a new Nicer to put up!


----------



## tie (Dec 8, 2000)

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.  Are there any issues I should be aware of for installing the security manager (i.e., should I install it statically or dynamically; if I install it statically, am I going to have to redo it all when I upgrade to OS X final?)  

[Edited by tie on 12-08-2000 at 12:26 AM]


----------



## IamBob (Dec 8, 2000)

> 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]


----------



## G4Rules (Dec 9, 2000)

> 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...


----------



## IamBob (Dec 9, 2000)

I never thought of that.

Thanks..works great!


----------



## IamBob (Dec 11, 2000)

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


----------



## IamBob (Dec 11, 2000)

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.


----------



## The DJ (Dec 11, 2000)

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:

```
/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


----------



## The DJ (Dec 11, 2000)

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


----------



## IamBob (Dec 12, 2000)

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! 

[Edited by IamBob on 12-12-2000 at 05:13 PM]


----------



## tie (Dec 12, 2000)

> _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.


----------



## The DJ (Dec 12, 2000)

> _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]


----------



## IamBob (Dec 12, 2000)

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.


----------



## The DJ (Dec 13, 2000)

> _Originally posted by IamBob _
> *Sounds easy enough...I'll have to try it out sometime when I actually need to. *



Try out this one first 
http://home.student.utwente.nl/d.hartman/watdoeik/NicerInstaller.tar.gz


----------



## The DJ (Dec 14, 2000)

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


----------



## IamBob (Dec 14, 2000)

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?


----------



## The DJ (Dec 15, 2000)

> _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


----------



## IamBob (Dec 16, 2000)

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


----------



## IamBob (Dec 19, 2000)

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:

```
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!!  

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]


----------



## The DJ (Dec 24, 2000)

> _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


----------



## IamBob (Dec 29, 2000)

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.


----------



## int69h (Jan 2, 2001)

Bob,
	If you were using ObjC, I believe the solution to your leak might lie in,

```
[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


----------



## tie (Jan 6, 2001)

> _Originally posted by tie _
> *Does anyone have any experience installing the javax.crypto framework?*



Okay, I can answer my own question:  

It is a known and documented bug that jce1.2.1 SealedObjects don\'t work properly if you install the jce as an \"installed\" extension.  So don\'t try.  

It is a known (but not documented: search for the \"cannot issue certs to trusted ca\" exception message) bug that Diffie-Hellman key exchange doesn\'t work with jce1.2.1 and anything earlier than java1.3.  The sample code won\'t even work.  This is a pretty serious problem, I wish I had saved an earlier jce version!  

Will MacOS X final include java1.3?


----------

