From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!tank.news.pipex.net!pipex!oleane!jussieu.fr!rain.fr!world-net!usenet Sat Mar 9 10:58:45 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!tank.news.pipex.net!pipex!oleane!jussieu.fr!rain.fr!world-net!usenet From: pamc@implicit.worldnet.com (Patrick MERISSERT-COFFINIERES) Newsgroups: comp.lang.java Subject: Re: help with a trivial piece of source code Date: Mon, 04 Mar 1996 19:28:02 GMT Organization: Implicit Software Corp. Message-ID: <4hfghp$mfl@aldebaran.sct.fr> Reply-To: pamc@implicit.worldnet.com NNTP-Posting-Host: client91.sct.fr X-Newsreader: Forte Free Agent 1.0.82 josh@cpsc.ucalgary.ca (Josh Heidebrecht) wrote: >Ok, I wanted to find out a bit about how arrays function in Java so I wrote >the following: ... > System.out.print("a is "); > for (i=0; i<10; i++) { > System.out.print(a[i] + " "); > } > > System.out.println(); > System.out.print("b is "); ... >Ok, looks pretty straight forward, but the only output I get is this: >a is 1 2 3 4 5 6 7 8 9 0 ... >and if System.out.println(); and System.out.print("b is "); are commented out >I don't even get information about the array 'a' displayed to the screen.. ... >Thanks for the help! I think System.out works with a "line discipline", which means that it waits for a newline character to flush its buffer to the console. If you add another "System.out.println()' at the end of your code, you shoud see "b is..." appear. From csus.edu!csulb.edu!newshub.csu.net!news.Cerritos.edu!news.Arizona.EDU!ennfs.eas.asu.edu!gatech!news.mathworks.com!zombie.ncsc.mil!cs.umd.edu!nntp.cs.umd.edu!league Sat Mar 9 11:02:07 1996 Path: csus.edu!csulb.edu!newshub.csu.net!news.Cerritos.edu!news.Arizona.EDU!ennfs.eas.asu.edu!gatech!news.mathworks.com!zombie.ncsc.mil!cs.umd.edu!nntp.cs.umd.edu!league From: league@cs.umd.edu (Christopher League) Newsgroups: comp.lang.java Subject: Re: java != C++ ??!! Date: 05 Mar 1996 02:40:19 GMT Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Message-ID: NNTP-Posting-Host: snocap.cs.umd.edu In-reply-to: thomast@berlin.snafu.de's message of Mon, 04 Mar 1996 11:45:53 GMT -----BEGIN PGP SIGNED MESSAGE----- In article <4hel2l$63p@unlisys.unlisys.net> thomast@berlin.snafu.de (Thomas Tomiczek) writes: > What about > #ifdef _DEBUG_ > to make a normal and a debug-version out of the same source? > Would be VERY useful for complicated Objects. I tend to agree with this point, although generally speaking, I'm glad to be rid of the preprocessor. They say the solution now is something like this: // class variable: static bool DEBUG = true; // inside any method of this class: if( DEBUG ) { : : } It isn't conditional compilation, but it does the job. If you're worried about the time wasted in checking the DEBUG flag in a production version, then go back to C/C++. This does have one nicety, in that it's easy to flag WHICH classes in your program to DEBUG. `Chris _____ Christopher League league@cs.umd.edu University of Maryland http://www.cs.umd.edu/users/league Department of Computer Science PGP Public Key available -----BEGIN PGP SIGNATURE----- Version: 2.6.2 Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface iQBVAwUBMTupLYpWZc1jv27RAQE9HgH+IAS1G+qHU0EaMtMgFFP8Vf7jaSqJqn2f c70dYsPULAHgLtLcU903AvoAG2yUB+WAkp+Xge2BgnaVMjB3O6vdPg== =gkDZ -----END PGP SIGNATURE----- From csus.edu!csusac!charnel.ecst.csuchico.edu!xmission!inquo!news.mira.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!floyd.sw.oz.au!usenet Sat Mar 9 11:02:24 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!xmission!inquo!news.mira.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!floyd.sw.oz.au!usenet From: jeremy@suede.sw.oz.au (Jeremy Fitzhardinge) Newsgroups: comp.lang.java Subject: Re: java != C++ ??!! Date: 5 Mar 1996 09:56:26 GMT Organization: Softway Pty Ltd Message-ID: <4hh34a$ccg@floyd.sw.oz.au> <4gmkt3$lro@scapa.cs.ualberta.ca> <4hcadg$cam@newsbf02.news.aol.com> <4hel2l$63p@unlisys.unlisys.net> NNTP-Posting-Host: suede.sw.oz.au X-Newsreader: knews 0.9.3 In-Reply-To: In article , league@cs.umd.edu (Christopher League) writes: >They say the solution now is something like this: > > // class variable: > static bool DEBUG = true; >[...] >It isn't conditional compilation, but it does the job. If you're >worried about the time wasted in checking the DEBUG flag in a >production version, then go back to C/C++. This does have one nicety, >in that it's easy to flag WHICH classes in your program to DEBUG. Actually, if you use static final boolean DEBUG = TRUE; then the compiler will eliminate the if statement check altogether, and either incorporate or exclude the debug code entirely. J From csus.edu!news.ucdavis.edu!agate!news.Stanford.EDU!nntp-hub2.barrnet.net!venus.sun.com!news2me.EBay.Sun.COM!engnews2.Eng.Sun.COM!positive!linden Sat Mar 9 18:59:22 1996 Path: csus.edu!news.ucdavis.edu!agate!news.Stanford.EDU!nntp-hub2.barrnet.net!venus.sun.com!news2me.EBay.Sun.COM!engnews2.Eng.Sun.COM!positive!linden From: linden@positive.eng.sun.com (Peter van der Linden) Newsgroups: comp.lang.java Subject: Re: Peer Date: 9 Mar 1996 23:59:13 GMT Organization: Sun Microsystems Computer Corporation Message-ID: <4ht60h$ofr@engnews2.Eng.Sun.COM> NNTP-Posting-Host: positive.eng.sun.com Cc: >Could someone please explain with a Peer is? Five word summary: you don't need to know. Longer explanation: these are the native window system objects that implement the AWT on each platform. You don't access them directly, and you never need worry about them. Mnemonic: Peer objects help you "peer" at the underlying window system. -- Peter van der Linden linden@eng.sun.com Java: as far away from C++ as possible, but no further. From csus.edu!newshub.csu.net!newsserver.sdsc.edu!news.tc.cornell.edu!newsstand.cit.cornell.edu!ub!dsinc!newsfeed.pitt.edu!scramble.lm.com!news.math.psu.edu!chi-news.cic.net!nntp.coast.net!news.sprintlink.net!news.umkc.edu!coleman Sat Mar 9 19:42:50 1996 Path: csus.edu!newshub.csu.net!newsserver.sdsc.edu!news.tc.cornell.edu!newsstand.cit.cornell.edu!ub!dsinc!newsfeed.pitt.edu!scramble.lm.com!news.math.psu.edu!chi-news.cic.net!nntp.coast.net!news.sprintlink.net!news.umkc.edu!coleman From: coleman@cstp.umkc.edu (Mike Coleman) Newsgroups: comp.lang.java Subject: [ANNOUNCE] jtags: make Java tags file with emacs' etags Date: 4 Mar 1996 08:45:36 GMT Organization: University of Missouri - Kansas City Message-ID: <4heajg$jnd@kasey.umkc.edu> NNTP-Posting-Host: chez-gnu.cstp.umkc.edu Do you edit Java source code with emacs (or maybe vi)? Do you use tags files? Then 'jtags' is just what you've been waiting for. Well, sort of. It'll do for the interim, until someone more properly adapts etags to Java. jtags is a script which invokes etags with a hairy set of --regex options which will recognize most class, interface, method declarations, and final class variables. It's not perfect, but it's pretty good, albeit a hideous hack, and certainly a lot better than nothing. See the script comments for caveats. If your current etags doesn't support --regex, you'll need to get a more current version. Cheers, --Mike #!/bin/sh # This is a shell archive (produced by GNU sharutils 4.1). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 1996-03-04 02:03 CST by . # Source directory was `/usr/local/home/coleman/bin'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 2239 -r-xr-xr-x jtags # 118 -rwxr-xr-x jtagsd # touch -am 1231235999 $$.touch >/dev/null 2>&1 if test ! -f 1231235999 && test -f $$.touch; then shar_touch=touch else shar_touch=: echo echo 'WARNING: not restoring timestamps. Consider getting and' echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 1231235999 $$.touch # # ============= jtags ============== if test -f 'jtags' && test X"$1" != X"-c"; then echo 'x - skipping jtags (file already exists)' else echo 'x - extracting jtags (text)' sed 's/^X//' << 'SHAR_EOF' > 'jtags' && #!/bin/sh X # jtags: run etags with Java language regex's # initial implementation the fault of Mike Coleman # possibly to be obsoleted by proper changes to etags X # $Id: jtags,v 1.6 1996/03/04 08:00:26 coleman Exp $ X # limitations: # - The biggie is that unmodified method definitions up to the initial '{' must # be on a single line in order to match. # - Some garbage (e.g., "if (a) {") will be included. As far as I can tell, # this shouldn't cause significant problems. (This could be mostly # eliminated by requiring that no white space appear between the method name # and '(' in definitions, but this would bite people that like such space.) X # clause 1 finds class/interface definitions (match to name) # clause 2 finds modified constructors (match to '(', then no '{') # (matches with '{' caught in clause 5, unfortunately) # clause 3 finds unmodified constructors (match to '{') # clause 4 finds modified non-constructor method definitions (match to '(') # clause 5 finds unmodified non-constructor method definitions (match to '{') # clause 6 finds final method variables (e.g., interface constants) # (match to '=') X exec etags --lang=none \ X --regex='/^[ \t]*\(\(abstract\|final\|public\)[ \t]+\)*\(class\|interface\)[ \t]+\([a-zA-Z_$][a-zA-Z0-9_$]*\)/' \ X --regex='@^[ \t]*\(\(public\|protected\|private\)[ \t]+\)+\([a-zA-Z_$][a-zA-Z0-9_$]*\)[ \t]*\(\[[ \t]*\]\)*([^{]*$@\3@' \ X --regex='@^[ \t]*\([a-zA-Z_$][a-zA-Z0-9_$]*\)[ \t]*\(\[[ \t]*\]\)*([^-~!%^&*(=+/<>:{};|)]*)[ \t]*\(throws[^{]*\)?[ \t]*{@\1@' \ X --regex='@^[ \t]*\(\(public\|protected\|private\|static\|abstract\|native\|final\|synchronized\)[ \t]+\)+\([a-zA-Z_$][a-zA-Z0-9_$]*[ \t]*\(\[[ \t]*\]\)*\)[ \t]+\([a-zA-Z_$][a-zA-Z0-9_$]*\)[ \t]*\(\[[ \t]*\]\)*(@\5@' \ X --regex='@^[ \t]*\([a-zA-Z_$][a-zA-Z0-9_$]*[ \t]*\(\[[ \t]*\]\)*\)[ \t]+\([a-zA-Z_$][a-zA-Z0-9_$]*\)[ \t]*\(\[[ \t]*\]\)*([^-~!%^&*(=+/<>:{};|)]*)[ \t]*\(throws[^{]*\)?[ \t]*{@\3@' \ X --regex='@^[ \t]*\(\(public\|protected\|private\|static\|transient\|volatile\)[ \t]+\)*final[ \t]+\(\(public\|protected\|private\|static\|transient\|volatile\)[ \t]+\)*\([a-zA-Z_$][a-zA-Z0-9_$]*[ \t]*\(\[[ \t]*\]\)*\)[ \t]*\([a-zA-Z_$][a-zA-Z0-9_$]*\)[ \t]*\(\[[ \t]*\]\)*[ \t]*=@\7@' \ X ${1+"$@"} SHAR_EOF $shar_touch -am 0304020096 'jtags' && chmod 0555 'jtags' || echo 'restore of jtags failed' shar_count="`wc -c < 'jtags'`" test 2239 -eq "$shar_count" || echo "jtags: original size 2239, current size $shar_count" fi # ============= jtagsd ============== if test -f 'jtagsd' && test X"$1" != X"-c"; then echo 'x - skipping jtagsd (file already exists)' else echo 'x - extracting jtagsd (text)' sed 's/^X//' << 'SHAR_EOF' > 'jtagsd' && #!/bin/sh X # drop a TAGS file for a whole hierarchy of .java files X exec jtags `find . -name '*.java' -type f -print` SHAR_EOF $shar_touch -am 0301182896 'jtagsd' && chmod 0755 'jtagsd' || echo 'restore of jtagsd failed' shar_count="`wc -c < 'jtagsd'`" test 118 -eq "$shar_count" || echo "jtagsd: original size 118, current size $shar_count" fi exit 0 -- Mike Coleman, Ctr for Telecomputing Research, http://ctr.cstp.umkc.edu/~coleman "The Internet is a powerful example of free speech and the free market in action; it is curious that the Net has alarmed the lawmakers of a nation founded on those principles." --Denise Caruso From csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!spool.mu.edu!munnari.OZ.AU!news.ecn.uoknor.edu!paladin.american.edu!howland.reston.ans.net!nntp.coast.net!zombie.ncsc.mil!news.mathworks.com!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!hursley.ibm.com!news Sat Mar 9 19:46:01 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!spool.mu.edu!munnari.OZ.AU!news.ecn.uoknor.edu!paladin.american.edu!howland.reston.ans.net!nntp.coast.net!zombie.ncsc.mil!news.mathworks.com!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!hursley.ibm.com!news From: David Mitchell Newsgroups: comp.lang.java Subject: Re: simple animation problem (duh!) Date: Tue, 05 Mar 1996 12:58:30 +0000 Organization: IBM Message-ID: <313C3A76.6B1F@hurpop.hursley.ibm.com> NNTP-Posting-Host: shrdlu.hursley.ibm.com James Closs wrote: > > Learning curve? More like a learning cliff! > > Please will someone tell me why the following code doesn't work. > I get absolutely nothing on screen, what I want is an image to be > drawn, then move from left to right. > > With the for loop taken out of the run method I get the image drawn once. > > Here's the source: I would also be grateful if anyone could point me to > any clear 'learning Java' sites, or source code for SIMPLE applets. > > cheers > > import java.awt.*; > import java.applet.*; > public class rocketFridge extends Applet implements Runnable{ > > protected boolean running = true; > protected Thread rocketThread=null; > protected Image rocketSprite; > int rocketV = 150; > int rocketH = 150; > > public void init () { > resize (300, 350); > > } > > public void start () { > rocketThread = new Thread (this); > rocketThread.start(); > } > > public void run () { > > rocketSprite = getImage(getDocumentBase(), "rocketFridge.gif"); > for (int i=0;i < 300; i++) { > rocketH++; > repaint(); > delay(); > } > } > > protected void delay (){ > for (int i=0; i<5000; i++); > } > > > public void paint (Graphics g) { > g.drawImage(rocketSprite, rocketH, rocketV, this); > } > > public void stop() { > } > } Use Thread.sleep(50) instead of your delay() method - you're not giving Java a chance to do the painting! Dave From csus.edu!csulb.edu!newshub.csu.net!usc!howland.reston.ans.net!newsfeed.internetmci.com!news.mathworks.com!uunet!in2.uu.net!psinntp!psinntp!psinntp!psinntp!webprod.lehman.com!news Sat Mar 9 20:13:36 1996 Path: csus.edu!csulb.edu!newshub.csu.net!usc!howland.reston.ans.net!newsfeed.internetmci.com!news.mathworks.com!uunet!in2.uu.net!psinntp!psinntp!psinntp!psinntp!webprod.lehman.com!news From: Dan Groner Newsgroups: comp.lang.java Subject: Math class exceptions... Not! Date: Mon, 04 Mar 1996 12:37:22 -0500 Organization: Lehman Brothers Message-ID: <313B2A52.41C67EA6@lehman.com> NNTP-Posting-Host: cfdev1172.lehman.com Math.sqrt() indicates in the code comment that it throws an Exception if the parameter is negative. The method declation includes a throws ArithmeticException. Running a simple example (Math.sqrt(-1)) indicates that Double.NaN is returned instead. log() and pow() also have similar comments and behavior. Returning special values (instead of throwing exceptions) would be consistent with Java's behavior in certain primitive operations (e.g., 0/0). So either the code comment is wrong and the throws clause is unneeded, or I'm confused. - Dan From csus.edu!druid.borland.com!news.sprintlink.net!newsfeed.internetmci.com!swrinde!elroy.jpl.nasa.gov!decwrl!enews.sgi.com!news.corp.sgi.com!user Sat Mar 9 21:37:40 1996 Path: csus.edu!druid.borland.com!news.sprintlink.net!newsfeed.internetmci.com!swrinde!elroy.jpl.nasa.gov!decwrl!enews.sgi.com!news.corp.sgi.com!user From: sandvik@sgi.com (Kent Sandvik) Newsgroups: comp.lang.java Subject: Re: getting environment variable Date: Fri, 08 Mar 1996 14:35:01 -0800 Organization: Silicon Graphics, Inc. Message-ID: NNTP-Posting-Host: mac-sandvik.engr.sgi.com In article <31409001.1DAD@scruznet.com>, Vijay Talati wrote: >If getenv in comp.lang.System is obsolete whats the right >method to use for getting environment variables? getEnv is obsoleted. You need to use the new way of setting properties when starting the java application, and reading them via GetProperties. Something like: % java -DMyProperty=blue myapplication.java String myProperty = System.getProperty("MyProperty"); --Kent Kent Sandvik, Silicon Graphics, Inc. Member of Technical Staff Email: sandvik@sgi.com Phone: +1 415 933-6417 http://reality.sgi.com/sandvik/ (sgi http:/kent.engr/) "May all developers be happy." From csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!gatech!news.mathworks.com!news.kei.com!nntp.coast.net!news.sprintlink.net!news.net-connect.net!news Sat Mar 9 21:42:07 1996 Path: csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!gatech!news.mathworks.com!news.kei.com!nntp.coast.net!news.sprintlink.net!news.net-connect.net!news From: Niels Gron Newsgroups: comp.lang.java Subject: Re: Possible dumb question Date: Sat, 09 Mar 1996 18:27:59 -0600 Organization: Net Connect, Ltd Message-ID: <3142220F.4CDC@net-connect.net> NNTP-Posting-Host: as03.net-connect.net malcolm@interele.demon.co.uk wrote: > > OK this may be a really dumb question to all the Java experts out > there but I'm only just beginning so give me a break... > > Why doesn't this code create a Dialog box and put a button on it ???? > > import java.awt.*; > import java.applet.*; > > public class nbcs extends Applet > { > > Frame d; > > public void init() > { > > d = new Frame(); > add(new Button("Show Window")); > add(new Button("Hide Window")); > d.add(new Button("Hide Window")); > } > > public boolean action( Event e, Object o ) > { > > if (o == "Show Window" ) > { > if (!d.isShowing()) > d.show(); > > } > > if (o == "Hide Window" ) > { > if (d.isShowing()) > d.hide(); > } > > return true; > } > } I had the same question a week ago ... I just figured it out ... you have to add have to set a layout manager; like this setLayout( null ); before you add any buttons. Or you can set any other layout. From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!qualcomm.com!qualcomm.com!not-for-mail Tue Mar 12 08:36:04 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!qualcomm.com!qualcomm.com!not-for-mail From: greg@qualcomm.com (Greg Noel) Newsgroups: comp.lang.java Subject: Re: Client-server - terminal emulator Date: 11 Mar 1996 13:58:42 -0800 Organization: QUALCOMM, Incorporated; San Diego, CA, USA Message-ID: <4i27mi$fse@qualcomm.com> NNTP-Posting-Host: guru.qualcomm.com In article <4hf3p1$ges@mercury.hgmp.mrc.ac.uk>, Geoff Gibbs wrote: >this is Jterm.java - the glass Teletype emulator I made some modifications to this, enough that you can actually use it to log on to the Telnet port of some machine. Enough of the Telnet protocol is implemented to make it interoperate with the Telnet server, but it is far from a complete job. It still needs a lot of work. In particular, it needs three major types of improvements: o It needs a AWT guru to creat a class that accepts input although it is not (directly) editable. This class should have only a vertical scroll and the ability to jump the displayed image to the bottom of the displayed region. o It needs a terminal emulator wizard to implement some sort of cursor control, so that the screen will act like, say, a VT100 or xterm. o It needs a Telnet weenie to implement the rest of the Telenet protocol needed for an interactive terminal (suppress go-ahead comes to mind). I am none of these things, so I must leave it up to others to complete. If someone wishes to take the gauntlet, I'd appreciate knowing about it, as I could use such a restricted terminal emulator. The revised class is attached below. -- Greg // Jterm.java - glass Teletype emulator import java.awt.*; import java.net.*; import java.io.*; public class Jterm extends java.applet.Applet implements Runnable { private String host; private int port = 23; private TextArea screen = new TextArea( "JTerm Dumb Glass TTY Terminal Emulator\n", 24, 80); private TextField keyboard = new TextField( "Type here please > ", 80); private Socket socket; private InputStream in; private OutputStream out; private Thread Display_Thread = null; public void init() { System.out.println("Call to init()."); keyboard.setFont(new Font("Courier", Font.PLAIN, 12)); add(keyboard); screen.setFont(new Font("Courier", Font.PLAIN, 12)); screen.setEditable(false); add(screen); /* * open the connection to the remote * and transmit characters back and forth */ try { if ((host = getCodeBase().getHost()) == null || host.equals("")) host = "localhost"; port = Integer.parseInt(getParameter("port")); System.out.println("Opening socket to " + host + " on port " + port); socket = new Socket(host, port); screen.appendText("Opened socket to " + host + " on port " + port + " from port " + socket.getLocalPort() + ".\n"); out = socket.getOutputStream(); DO(TelnetECHO); // request remote echo in = socket.getInputStream(); if (Display_Thread == null) { // copy socket input into screen Display_Thread = new Thread(this); Display_Thread.start(); } System.out.println("Socket: " + socket.toString() + "\n\t" + out.toString() + "\n\t" + in.toString()); } catch(Exception e) { System.out.println("Caught exception in init(): " + e.getMessage()); } resize(size().width,size().height); } private boolean clearField = true; public boolean handleEvent(Event e) { if (e.id == Event.KEY_PRESS) { // System.out.println("handleEvent got character " + e.key // + " giving " + (char)(e.key) + "."); if (clearField) { keyboard.setText(""); clearField = false; } if (e.key == '\n' || e.key == '\r') { clearField = true; } try { out.write((byte)e.key); //out.flush(); if (remote_state[TelnetECHO] == false) { displayChar(e.key); } } catch ( Exception ex ) { System.out.println( "Caught exception in handleEvent(): " + ex.getMessage()); } return super.handleEvent(e); //return true; } else { // System.out.println("Unhandled event " + e.id); return super.handleEvent(e); } } public void run() { System.out.println("Call to run()."); try while (true) { int c = in.read(); if (c == -1) { throw new java.io.EOFException(); } if (c == 0) { // ignore delay padding continue; } if (c == 255) { // telnet escape---if not an IAC, // negoiate with other end if ((c = in.read()) != 255) { Telnet(c); continue; } } displayChar(c); } catch (java.io.EOFException e) { // do something with EOF on socket.... screen.appendText( "\r\nConnection closed by remote...."); try { System.exit(0); } catch (Throwable t) { // Security exception if run in an applet Display_Thread = null; return; } } catch (java.io.IOException e) { System.out.println("Caught exception in screen io: " + e.getMessage()); } } private void displayChar(int c) // display on screen { // System.out.println("Displaying " + c); // there ought to be a better way to do this.... StringBuffer s = new StringBuffer(1); s.setLength(1); s.setCharAt(0, (char)c); screen.appendText(s.toString()); } private void Telnet(int c) throws java.io.IOException { switch (c) { case -1: throw new java.io.EOFException(); case 254: // DON'T TelnetDONT(in.read()); return; case 253: // DO TelnetDO(in.read()); return; case 252: // WON'T TelnetWONT(in.read()); return; case 251: // WILL TelnetWILL(in.read()); return; case 250: // Subnegotiation start return; case 249: // Go ahead return; case 248: // Erase line return; case 247: // Erase character return; case 246: // Are you there? return; case 245: // Abort output return; case 244: // Interrupt process return; case 243: // Break return; case 242: // Data mark return; case 241: // NOP return; case 240: // Subnegotiation end return; default: System.out.println("Escape " + c); } } // status of selected Telnet options private boolean[] remote_state = new boolean[256]; private boolean[] local_state = new boolean[256]; // Telnet options private static final int TelnetECHO = 1; // remote echo // option string private byte[] opt_str = { (byte)255, 0, 0 }; // say that I'm doing this private synchronized void WILL(int code) throws java.io.IOException { opt_str[1] = (byte)251; opt_str[2] = (byte)code; out.write(opt_str, 0, 3); local_state[code] = true; } // say that I'm not doing this private synchronized void WONT(int code) throws java.io.IOException { opt_str[1] = (byte)252; opt_str[2] = (byte)code; out.write(opt_str, 0, 3); local_state[code] = false; } // ask him to do this private synchronized void DO(int code) throws java.io.IOException { opt_str[1] = (byte)253; opt_str[2] = (byte)code; out.write(opt_str, 0, 3); remote_state[code] = true; } // ask him not to do this private synchronized void DONT(int code) throws java.io.IOException { opt_str[1] = (byte)254; opt_str[2] = (byte)code; out.write(opt_str, 0, 3); remote_state[code] = false; } // ask me to do this private synchronized void TelnetDO(int code) throws java.io.IOException { if (local_state[code] == false) { // Reject any option we don't know switch (code) { //case TelnetECHO: // we know how to do this // WILL(code); break; default: // Reject any option we don't know WONT(code); } } } // ask me not to do this private synchronized void TelnetDONT(int code) throws java.io.IOException { // if we're currently doing it, stop if (local_state[code] == true) { WONT(code); // Send WON'T as ACK } } // say that he will do this private synchronized void TelnetWILL(int code) throws java.io.IOException { if (remote_state[code] == false) { switch (code) { case TelnetECHO: // we know how to do this DO(code); break; default: // Reject any option we don't know DONT(code); } } } // say that he won't do this private synchronized void TelnetWONT(int code) throws java.io.IOException { // if we think he's doing it, stop if (remote_state[code] == true) { // Accept any remote DON'T option // Send DON'T as ACK DONT(code); } } public void start() { System.out.println("Call to start()."); } public void stop() { System.out.println("Call to stop()."); } public void destroy() { System.out.println("Call to destroy()"); if (Display_Thread != null) { Display_Thread.stop(); Display_Thread = null; } try { in.close(); out.close(); } catch (IOException e) { System.out.println("Caught exception in destroy(): " + e.getMessage()); } } } -- -- Greg Noel, UNIX Guru greg@qualcomm.com or greg@noel.cts.com From csus.edu!druid.borland.com!news.sprintlink.net!newsfeed.internetmci.com!uwm.edu!vixen.cso.uiuc.edu!mtravis Wed Mar 13 08:10:40 1996 Path: csus.edu!druid.borland.com!news.sprintlink.net!newsfeed.internetmci.com!uwm.edu!vixen.cso.uiuc.edu!mtravis From: mtravis@students.uiuc.edu (travis matthew burns) Newsgroups: comp.lang.java Subject: Re: getting size of applet as two integer Date: 10 Mar 1996 22:19:34 GMT Organization: University of Illinois at Urbana Message-ID: <4hvkhm$g9v@vixen.cso.uiuc.edu> NNTP-Posting-Host: ux5.cso.uiuc.edu lvgeuns@laser.iaehv.nl (Edward van Geuns) writes: >Dear newsgroup, >Does anyone know how to get the height and width of an Applet as an >integer? I tried using size(), it is in java.awt.Dimension and than >toString(), same class,but could not find out how to get the *integer* >values out of the string he gave me, which looked something like: > > Hello, Just use size().width and size().height or you can do something like this inside your Applet: Dimension windowSize=size(); int widthOfWindow=windowSize.width; int heightOfWindow=windowSize.height; size() returns a Dimension object and width and height are publicly-accessible members of Dimension. Carpe diem, Java Boy Matthew Travis, mtravis@uiuc.edu From csus.edu!news.ucdavis.edu!agate!dog.ee.lbl.gov!news.cs.utah.edu!cs.utexas.edu!venus.sun.com!news2me.EBay.Sun.COM!engnews1.Eng.Sun.COM!usenet Wed Mar 13 08:13:44 1996 Path: csus.edu!news.ucdavis.edu!agate!dog.ee.lbl.gov!news.cs.utah.edu!cs.utexas.edu!venus.sun.com!news2me.EBay.Sun.COM!engnews1.Eng.Sun.COM!usenet From: toml@longspeak.Central.Sun.COM (Tom LaStrange) Newsgroups: comp.lang.java Subject: Re: All Classes from Object? Date: 11 Mar 1996 16:20:57 GMT Organization: Sun Microsystems, Inc., Colorardo Springs, CO Message-ID: NNTP-Posting-Host: longspeak.central.sun.com In-reply-to: "D. M. Kowallek"'s message of Tue, 5 Mar 1996 22:15:27 GMT In article <313CBCFF.878@iglou.com> "D. M. Kowallek" writes: > Is ... > > public class foo > { > ... > } > > ... the same as ... > > public class foo extends Object > { > ... > } > > ...? > > In other words, is the 1st extended from Object by > default? Yes. -- Tom LaStrange mailto:toml@rmtc.central.sun.com From csus.edu!newshub.csu.net!news.Cerritos.edu!news.Arizona.EDU!CS.Arizona.EDU!noao!ennfs.eas.asu.edu!gatech!newsfeed.internetmci.com!swrinde!news.uh.edu!usenet Wed Mar 13 09:23:01 1996 Path: csus.edu!newshub.csu.net!news.Cerritos.edu!news.Arizona.EDU!CS.Arizona.EDU!noao!ennfs.eas.asu.edu!gatech!newsfeed.internetmci.com!swrinde!news.uh.edu!usenet From: Jeff M Younker Newsgroups: comp.lang.java Subject: Re: Object Array Question... Date: Tue, 12 Mar 1996 11:51:03 -0600 Organization: University of Houston High Performance Computing Center Message-ID: <3145B987.49EE@uh.edu> NNTP-Posting-Host: farabi.hpc.uh.edu Michele Rosen wrote: > I'm trying to create an array of objects, all different but > sharing the same parent class, and then accessing the subclasses' > methods. A snippet of code > is shown below: 1. Let's examine your problem. The compiler knows that the array is made up of "Layers". Now pretend that you are the compiler. Somebody asks you to pull a "Layer" out of a barrel of "Layers". You pull something out (now don't peek). Can you execute "method1" on this "Layer"? I don't know. You don't know. Nobody knows. It is just a "Layer". Until you check (cast) you "can't" know. This is what the compiler error is about. 2. Now, this may sound like a silly question, but why are you making "InputLayer" and "OutputLayer" inherit from "Layer"? The two classes don't shave anything in common. "Superclasses" are used for sharing common functionality. They are not used to group things together arbitrarily (this is what packages are for). 3. Use abstract classes to share code. Use interfaces to declare functionality. - Jeff Younker - jeff@uh.edu - These are my opinions, and not UH's - From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!usenet.ins.cwru.edu!gatech!newsfeed.internetmci.com!tank.news.pipex.net!pipex!dish.news.pipex.net!pipex!news.pncl.co.uk!pncl.co.uk!mguile Wed Mar 13 09:24:10 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!usenet.ins.cwru.edu!gatech!newsfeed.internetmci.com!tank.news.pipex.net!pipex!dish.news.pipex.net!pipex!news.pncl.co.uk!pncl.co.uk!mguile From: Mark Guile Newsgroups: comp.lang.java Subject: Re: Object Array Question... Date: Mon, 11 Mar 1996 21:26:59 +0000 Organization: NIP Distribution: world Message-ID: <8nc1NAAjqJRxEwhN@pncl.co.uk> Reply-To: Mark Guile NNTP-Posting-Host: login38.pncl.co.uk X-Newsreader: Turnpike Version 1.11 In article <314483DE.198D@cyberenet.net>, Michele Rosen writes [snip] >abstract class Layer >{} >class InputLayer extends Layer >{ method1(){}; >} >class OutputLayer extends Layer >{ method2(){}; >} >class MakeLayers >{ Layer[] layernumber = new Layer[MAX_LAYERS]; // The compiler has no > layernumber[0] = new InputLayer(); // problem with these > layernumber[1] = new OutputLayer(); // lines... > > layernumber[0].method1(); // This line bombs. >} > >When the compiler gets to the last line it says 'Method method1 not found in >class Layer'?! I've tried stuffing the Layer subclasses into a Vector but >that didn't work either. Is the above technique inherently flawed or am I [snip] Inherently flawed, very good. method1 isn't in Layer, it's in InputLayer. If you want layernumber[0] to be treated as an instance of InputLayer then you need to explicitly cast it like this: ((InputLayer)layernumber[0]).method1(); If you try to cast layernumber[1] to an instace of InputLayer then a runtime exception will be thrown because layernumber[1] is an OutputLayer, not an InputLayer. This is probably not the best way to do what you want to do, to use this method of calling member functions you have to know which type each member of the array is, you could use the instanceof operator to find out but this is can get very untidy if you have a lot of diferent types and you have to know all the tpyes you are going to use when you write the calls. A better sloution is to use polymorphism something like this: abstract class Layer { public abstract void methodx(); } class InputLayer extends Layer { public void methodx(){ /* Do something */ }; } class OutputLayer extends Layer { public void methodx(){ /* Do something else */ }; } class MakeLayers { Layer[] layernumber = new Layer[MAX_LAYERS]; layernumber[0] = new InputLayer(); layernumber[1] = new OutputLayer(); layernumber[0].methodx(); // Call some implementation of methodx() } It is ok to call methodx() because it is a member of Layer. The appropriate implementation for the derived class is automaticaly called. Hope this helps -- Mark Guile mark@nipltd.com New Information Paradigms Ltd. http://www.nipltd.com/ From csus.edu!newshub.csu.net!news.Cerritos.edu!news.Arizona.EDU!math.arizona.edu!noao!ncar!csn!news-1.csn.net!gw1.att.com!cnn.Princeton.EDU!rogue.princeton.edu!jhammons Wed Mar 13 09:25:37 1996 Path: csus.edu!newshub.csu.net!news.Cerritos.edu!news.Arizona.EDU!math.arizona.edu!noao!ncar!csn!news-1.csn.net!gw1.att.com!cnn.Princeton.EDU!rogue.princeton.edu!jhammons From: jhammons@rogue.princeton.edu (Jesse M. Hammons) Newsgroups: comp.lang.java Subject: Re: Object Array Question... Date: 11 Mar 1996 22:04:24 GMT Organization: Princeton University Message-ID: <4i2818$c0r@cnn.Princeton.EDU> NNTP-Posting-Host: gambit.princeton.edu In article <314483DE.198D@cyberenet.net>, Michele Rosen wrote: >Hi, >As a newbie to Java, this question may be easy, but it has me stumped and any >help would be appreciated. > >I'm trying to create an array of objects, all different but sharing the same >parent class, and then accessing the subclasses' methods. A snippet of code >is shown below: > >abstract class Layer >{} >class InputLayer extends Layer >{ method1(){}; >} >class OutputLayer extends Layer >{ method2(){}; >} >class MakeLayers >{ Layer[] layernumber = new Layer[MAX_LAYERS]; // The compiler has no > layernumber[0] = new InputLayer(); // problem with these > layernumber[1] = new OutputLayer(); // lines... > > layernumber[0].method1(); // This line bombs. >} > >When the compiler gets to the last line it says 'Method method1 not found in >class Layer'?! I've tried stuffing the Layer subclasses into a Vector but >that didn't work either. Is the above technique inherently flawed or am I >missing a fundamental concept somewhere? (Or should I stop listening to >Motorhead while programming) > Well, layernumber[0] is of class Layer, so the compiler is right to give an error message. What you need to do is inform the compiler of facts which you know, such as layernumber[0] is an instance of InputLayer. You could do something like: ((InputLayer)layernumber[0]).method1() //cast it as an InputLayer. If you are going to loop through the array, you may need to do something like this: for(int i = 0; i < layernumber.length; i++) { Layer l = layernumber[i]; if (l instanceof InputLayer) ((InputLayer)l).method1(); else if (l instanceof OutputLayer) ((OutputLayer)l).method2(); else //error? } good luck, -- - Jesse http://www.cs.princeton.edu/~jhammons/java *Java Powered!* From csus.edu!csulb.edu!drivel.ics.uci.edu!news.claremont.edu!nntp-server.caltech.edu!fnnews.fnal.gov!uwm.edu!vixen.cso.uiuc.edu!newsfeed.internetmci.com!in2.uu.net!news-relay.eworld.com!zdc!news4.noc.netcom.net!symiserver2.symantec.com!usenet Wed Mar 13 09:57:59 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.claremont.edu!nntp-server.caltech.edu!fnnews.fnal.gov!uwm.edu!vixen.cso.uiuc.edu!newsfeed.internetmci.com!in2.uu.net!news-relay.eworld.com!zdc!news4.noc.netcom.net!symiserver2.symantec.com!usenet From: Roger Bowman Newsgroups: comp.lang.java Subject: Wanted to let you know Cafe is available now Date: Tue, 12 Mar 1996 19:30:46 -0800 Organization: Symantec Corp, Cupertino CA Headquarters Message-ID: <31464166.7FFD@symantec.com> NNTP-Posting-Host: 155.64.35.167 I) ANNOUNCING... We are pleased to announce that Symantec Cafe is now available for purchase from major resellers and mail-order houses nationwide, as well as from our web server. This version runs on Windows 95 and Windows NT. The 90-day promotional price is $129.95. * This includes a one-year subscription to our web site for downloading updates to Cafe and to the JDK. ** This also includes the Symantec Just-In-Time compiler which will be made available on our web site in March for Cafe owners. Resellers have been receiving many pre-orders and may risk selling out before receiving the first shipment from Symantec. We recommend you reserve a copy with one of the resellers listed below to ensure receive your product from the first in-store delivery. II) ABOUT CAFE Cafe is a complete Java development tool for creating Java applets and applications in Windows NT and Windows 95. Cafe is a standalone product dedicated to Java. You do not need a C++ tool, and Cafe comes with the Sun JDK 1.0. Everything you need to develop Java applets and applications for the web is in Cafe. Cafe includes: * A Java source editor, with syntax highlighting, configurable keystrokes, auto-indentation, column select, bookmarks, goto method, goto matching delimiter, advanced backup options, and a macro recorder. You can also right-click on any method and goto the source definition. * A GUI debugger. Now you can debug your multi-threaded applets and applications in a Windows-hosted debugger. You can view the values of your variables in a data window, view the call chain for individual execution threads, and you can freeze and thaw threads from the thread window. * Visual Design Tools. Cafe Studio creates forms and menus for your applets and application windows. It generates Java source code and adds it to your project automatically. It provides for the creation of event handlers the form and menu objects. It also allows you to specify a layout manager for the main panel and to create embedded subpanels each with unique layout managers. * Class Editor. This three-pane editor provides a neat and concise way to view your classes. After parsing your code, or optionally all of the Java system files source code, the classes are displayed by package for you to select. The member methods of the selected class are displayed on the right, and the code for the selected method is displayed in a full editing pane on the bottom. You can add new classes and methods via helpful dialogs using this two-way tool. * Hierarchy Editor. This two-way tool provides a visual representation of the custom classes in your Java project. From the Settings menu, you can invoke a members subwindow which displays the methods of the classes real-time as you click amongst the classes. This is a two-way tool, so you can right-click to create new classes and methods. * Project System. This management tool displays all of the files in your project ordered by name, extension, path, or date. Double-clicking any file opens the editor. Right-clicking on a file sets file-level options. Right-clicking on the project name allows you to build or set your build and target options visually. * Faster Compiler. Symantec engineered a new, optimized native compiler to create your bytecodes twelve times faster than the JDK compiler. The number of lines compiled an any error messages are displayed in the output window. Double-clicking on an error takes you to the offending line. * Help Files, Samples, and a Tutorial. Symantec provides the Java API reference and the language reference as Windows help files. Pressing F1 in the editor while positioned on a method will invoke help on that method. We provide a Java programming tutorial with dozens of related samples applets. * The full release 1.0 of the Sun Java Development Kit (JDK) is included in Cafe, so you get all of the Java classes and their source code, the samples, and the tools. III) CAFE RESELLERS EggHead 1-800-344-4323 http://www.egghead.com/ Fry's Electronics Best Buy CompUSA 1-800-266-7872 http://www.compusa.com/ Computer City http://www.tandy.com/cc/ccmain.html ProVantage 1-800-336-1166 http://www.provantage.com/ Programmer's Paradise 1-800-213-4524 http://www.p.paradise.com Programmer's SuperShop 1-800-421-8006 http://wheat.symgrp.com/symgrp/supershops/home.html and many more regional outlets. IV) ONLINE PURCHASING AND DOWNLOAD Symantec is also providing Cafe via a secure commerce server. http://cafe.symantec.com You can view information and screenshots on the product prior to deciding to buy. Then you provide a credit card number and you are given a user name and password with which you can download your copy of Cafe. Everything in the box is available via the download. All documentation is online. You may opt to download the core product and you may return for the samples, tutorials, and help files later if you wish. * The credit card information is fully encrypted during transmission to ensure the protection of your information. V) WHERE TO SEE CAFE Symantec will be demonstrating Cafe at the following shows and events: Java Day - March 15, Washington D.C. Software Development West - March 26-28, San Francisco, CA Mountain View Java User Group - March 27, Mountain View, CA IntraNet - April 8-10, New York, NY Java Day - April 25, Atlanta, GA Java Developer's Conference - May 13-15, New York, NY ... and many more locations throughout the year VI) FOR MORE INFORMATION You will find more information about Cafe on our web site at http://cafe.symantec.com Or you may drop an email to javainfo@symantec.com and ask a specific question. We are currently receiving an enormous amount of inquiries, so please allow a couple of days to receive your reply. VII) CAFE FOR MACINTOSH Symantec is working on a standalone Cafe product for the Macintosh. It will be available later this year. In the interim, we have created an update to our PowerMac C++ product which integrates the JDK for Mac and makes the C++ environment Java-aware. This update is named Caffeine and is FREE from our webpage. You must have already installed Symantec C++ 8.0.4 to your Macintosh hard disk prior to running the update. Using the update, you can code, compile, and test your Java applications from the Mac IDE. The integration is pretty seamless and offers a better environment than many of the current offerings for Macintosh. We have received a lot of positive feedback on this solution and we invite you to try it. VIII) SUPPORT FOR CAFE Symantec will be providing support for Cafe via the Internet, CompuServe, and telephone assistance. * Internet support is via the Java newsgroup comp.lang.java * CompuServe support is via GO SYMDEVTOOL section 12 - Cafe * 90-days of free phone support: 1-541-465-8470. Additional phone support plans are available providing contract support with unlimited calls and an 800 number. Get information on these plans at 1-800-441-7234. ========== We wish you the best of success in using Cafe, and eagerly look forward to seeing your new web applets developed in Cafe. Sincerely, Symantec Development Tools Team From dick Wed Mar 13 09:30 PST 1996 From: dick (Dr. Richard Botting) Date: Wed, 13 Mar 1996 08:58:14 -0800 Message-Id: <199603131658.IAA18454@csci.csusb.edu> Subject: (fwd) List of Netscape 2.0 Vulnerabilities Newsgroups: comp.lang.java,comp.lang.javascript,de.org.ccc,comp.infosystems.www.browsers.misc Organization: CS Dept., Calif. State Univ., San Bernardino Path: csus.edu!news.ucdavis.edu!library.ucla.edu!nntp.club.cc.cmu.edu!cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!news.sprintlink.net!imp.ch!uni-erlangen.de!winx03!not-for-mail From: cip230@cip.physik.uni-wuerzburg.de (Stefan Keller) Newsgroups: comp.lang.java,comp.lang.javascript,de.org.ccc,comp.infosystems.www.browsers.misc Subject: List of Netscape 2.0 Vulnerabilities Date: 10 Mar 1996 17:04:53 GMT Organization: CipPool der Physikalischen Institute, Uni Wuerzburg Message-ID: <4hv23l$96c@winx03.informatik.uni-wuerzburg.de> NNTP-Posting-Host: wpax05.physik.uni-wuerzburg.de X-Newsreader: TIN [UNIX 1.3 950824BETA PL0] Xref: csus.edu comp.lang.java:30476 comp.lang.javascript:1961 de.org.ccc:13832 comp.infosystems.www.browsers.misc:6443 It's about time for a comprehensive list of the vulnerabilities in Netscape 2.0. I'm not an expert. But here's my draft. Maybe y'all could elaborate a bit on it and then we spread the word.. =) List of Vulnerabilities in Netscape 2.0 (darft) --------------------------------------- 1. Javascript Bugs: 1.1 Javascript makes user's browser send an email (from user's account) to an address defined by the script. More Info: (first sighting) http://www.popco.com/grabtest.htm 1.2 John Robert LoVerso's Bug: Javascript opens small window and uses it to monitor the activity of user's browser, grabs the URLs of open documents and sends them to remote server. More Info: http://www.osf.org/~loverso/javascript/track-me.html 1.3 Javascripts sends recursive directory listing of the user's local disk and all disks mounted to any address on the Internet. More Info: http://www.osf.org/~loverso/javascript/track-me.html 1.4 Further holes in Beta Version of Netscape 2.0 More Info: http://www.c2.org/~aelana/javascript.html 2. Java Bugs: 2.1 Drew Dean's Bug: A hole in the implementation that allows Applets to make connections to any host on the internet, that is once download on user's machine they can try to connect (rsh/rlogin/rcp) on (trusted) machines on the user's local network (even behind firewalls). More Info: http://www.cs.princeton.edu/~ddean/java/ THERE'S A PATCH FOR THIS PROBLEM. (link on dean's page) 2.2 David Hopwood's Bug (see RISKS DIGEST 17:87 in comp.risks): You view attacker's site, when -secretly- two files get installed in your Netscape cache, allowing an applet to run arbitrary code with the permissions of the user. That is: As soon as you view attacker's web page, he can run commands on your machine. 3 Disabling them: I haven't read a way to deal with Problem 1.1, 1.2, 1.3. (Disabling Java won't help with them.) With 2.1, 2.2 'Disable Java' is supposed to help. As far as I know, there is a patch for Problem 2.1, but not for 2.2 - is that correct? Disclaimer: I'm not an expert. This is draft version. I might be wrong. (Just flame me into oblivion.. =] ) Stefan -- http://cip.physik.uni-wuerzburg.de/~cip230 _.:;._ You can finger phone: (+49) 931 70564 12 (LN2 Heat Exchange Lab): my public key. 1024/510CA335 : 85 66 A5 53 A4 96 6F EB 43 C4 5A 33 B6 BF 9F 05 -- dick botting http://www.csci.csusb.edu/dick/signature.html Disclaimer: CSUSB may or may not agree with this message. Copyright(1996): Copy freely but say where it came from. I have nothing to sell, and I'm giving it away. From csus.edu!news.ucdavis.edu!agate!news.Stanford.EDU!nntp-hub2.barrnet.net!hookup!news.mathworks.com!tank.news.pipex.net!pipex!warwick!sunsite.doc.ic.ac.uk!sunews!sutf1!ssu94102 Tue Mar 19 07:23:22 1996 Path: csus.edu!news.ucdavis.edu!agate!news.Stanford.EDU!nntp-hub2.barrnet.net!hookup!news.mathworks.com!tank.news.pipex.net!pipex!warwick!sunsite.doc.ic.ac.uk!sunews!sutf1!ssu94102 From: "XOR Man (Gerard Davison)" Newsgroups: comp.lang.java Subject: Re: System.in.read() errors.... Date: Tue, 19 Mar 1996 11:48:58 +0000 Organization: University of Reading, U.K. Message-ID: NNTP-Posting-Host: sutf1.reading.ac.uk In-Reply-To: <4i06qb$k4g@netaxs.com> On 11 Mar 1996, Captain Ahab wrote: > ok, i'm really desperate.... I just don't get it. I just want to get a > character from the keyboard, and it won't work. I have the Java! 2.0 beta > book and i'm doing _exactly_ what it does: > > a = (char)System.in.read(); > > after which i check the character using a switch. At compile time i get an > error that says: > > Exception java.io.IOException must be caught, or it must be declared in the > throws clause of this method. > The error means that you have to have something like: try { a = (char)System.in.read(); } catch (IOException e) { //handle IO error } Gerard --- Mulder: "Hey Scully, do you believe in the afterlife?" Scully: "I'd settle for a life in this one." -The X-Files, _Shadows_ (GMDavison@iee.org) From csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!newsfeed.internetmci.com!in2.uu.net!sleepy.inch.com!port172.dialup.inch.com!user Thu Mar 21 09:38:48 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!newsfeed.internetmci.com!in2.uu.net!sleepy.inch.com!port172.dialup.inch.com!user From: elharo@sunsite.unc.edu (Elliotte Rusty Harold) Newsgroups: comp.lang.java Subject: Re: Binary Trees - How? Date: Tue, 19 Mar 1996 17:24:10 -0500 Organization: Cafe Au Lait Message-ID: NNTP-Posting-Host: port172.dialup.inch.com In article <4i48te$o6k@loki.brunel.ac.uk>, cs92mms2@brunel.ac.uk (Madhu Surendranath) wrote: >Hi all, > >Can somebody tell me whether it is possible to create a binary tree of objects? > >Now, I know Java does not have external pointers, and this is how I would creat >such a structure in C++, so any ideas? Here's a few notes I made about trees for my upcoming book. This is for doubles but it would work for objects if you provide and use your own compare method. (The lack of both method pointers and parameterized types reall hurts here.) Corrections and comments are appreciated. A tree data structure consists of nodes, just like a linked list. Each node contains some data and references to zero or more children. The first node of the tree is called the root and is itself not the child of any other node. All other nodes are the child of exactly one node which is called the parent. Nodes without any children are called leaves. Many applications only need a tree in which there are at most two children of any given node. This is called a binary tree. The two children of each node are called the left child and the right child. Either or both children may be null. A non-binary tree would include a Vector of nodes as the children. Binary trees are most often used to store sorted data. Binary trees can sort data as it arrives, rather having to first wait for all the data to be accumulated as an array or a Vector would. Program 22.6 is a tree which can be used to store a sorted list of doubles. The tree is initialized with a number thatıs placed at the root. After the construction of the tree, values are added to the tree through its store method. Program 22.6 shows a treenode class for a binary tree of doubles. Program 22.6 A node of a binary tree public class treenode { double data; treenode left; treenode right; public treenode (double d) { data = d; left = null; right = null; } public void store (double d) { if (d <= data) { if (left == null) left = new treenode(d); else left.store(d); } else { if (right == null) right = new treenode(d); else right.store(d); } } public void print() { if (left != null) left.print(); System.out.println(data); if (right != null) right.print(); } } The store method is the key to the tree. As values are put in the tree theyıre compared with the value of the root. If a value is smaller than or equal to the root it moves down the left-hand side of the tree. Otherwise it moves down the right. If the child it moves to is null, then a new leaf node is created and the value stored there. Otherwise the value is tested against the value stored in the child and moves to the left or right according to whether it is or isnıt larger than the childıs value. This process continues recursively until eventually the value is put into a new node. When values are taken out of the tree in the print method they are returned in sorted order via the recursive procedure print. Adding an element to a tree is quite fast. Furthermore since you generally donıt have to process more than a few elements to find any one piece of data, trees can be much faster for random access than Vectors and compare favorably with arrays. Itıs almost always faster to insert a sorted element in a binary tree than in a vector or an array. The only exception would be when the data arrives presorted. Program 22.7 demonstrates the utility of a sorted binary tree by storing ten random numbers into a tree, and then printing them out. Program 22.7 Tree sort public class treesort { public static void main (String[] args) { treenode root = new treenode(Math.random()); for (int i = 1; i < 10; i++) { root.store(Math.random()); } root.print(); } } -- Elliotte Rusty Harold elharo@sunsite.unc.edu elharo@shock.njit.edu webmaster@nymug.org From csus.edu!news.ucdavis.edu!agate!newsxfer2.itd.umich.edu!newsfeed.internetmci.com!panix!not-for-mail Thu Mar 21 09:45:33 1996 Path: csus.edu!news.ucdavis.edu!agate!newsxfer2.itd.umich.edu!newsfeed.internetmci.com!panix!not-for-mail From: isc@panix.com (David Koosis) Newsgroups: comp.lang.java Subject: Re: Help: Subclassing constructors Date: 13 Mar 1996 21:12:39 -0500 Organization: ISC Consultants Inc. Message-ID: <4i7van$n4h@panix.com> Reply-To: dkoosis@iscinc.com NNTP-Posting-Host: panix.com In <4i7jar$2hi@decaxp.harvard.edu> robison@nucleus.harvard.edu (Keith Robison) writes: >graeme (csi@iconz.co.nz) wrote: >: I am trying to subclass classes which require parameters for their >: constructors. Eg the Dialog class requires the parent Frame and the modal >: status. >: In C++, you can do this by declaring the constructor >: SubDialog(Frame f, boolean m) : Dialog(f, m) >: { > SubDialog (Frame f, boolean m) > { > super(f,m); I find the following statement to be a useful mnemonic: "Constructor invocation is always the first thing in a method." (Either the programmer explicitly calls one of super's constructors, or the compiler implicitly calls super's default constructor.) It's a compile-time error to put any statements before the call to super's constructor. //dk -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ISC Consultants, Inc. +1 212-477-8800 "Quality Software Development Since 1973" C++ Delphi OCX's Java Paradox From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!newsfeed.internetmci.com!news.mathworks.com!zombie.ncsc.mil!admaix.sunydutchess.edu!ub!newsstand.cit.cornell.edu!news.tc.cornell.edu!newsserver.sdsc.edu!news.cerf.net!news.lainet.com!nntp2.cerf.net!paperboy.ast.com!news Thu Mar 21 09:45:55 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!newsfeed.internetmci.com!news.mathworks.com!zombie.ncsc.mil!admaix.sunydutchess.edu!ub!newsstand.cit.cornell.edu!news.tc.cornell.edu!newsserver.sdsc.edu!news.cerf.net!news.lainet.com!nntp2.cerf.net!paperboy.ast.com!news From: James Hugard Newsgroups: comp.lang.java Subject: Re: Help: Subclassing constructors Date: Tue, 19 Mar 1996 17:17:28 -0800 Organization: AST Research, Inc. Message-ID: <314F5CA8.174F@ast.com> NNTP-Posting-Host: jhugard.ast.com graeme wrote: > > I am trying to subclass classes which require parameters for their > constructors. Eg the Dialog class requires the parent Frame and the modal > status. > > In C++, you can do this by declaring the constructor > > SubDialog(Frame f, boolean m) : Dialog(f, m) > { ... > > This doesn't seem to work in Java. Am I missing something obvious? Any > help appreciated. > > Thanks > Graeme Edwards Graeme: What you want is: SubDialog( Frame f, boolean m ) { super( f, m ); { ... This also allows calling one's own constructors: SubDialog( Frame f ) { this( f, true ); { ... "this(...)" and "super(...)" are only allowed on the first line of a constructor, so the following produces a compiler error: SubDialog( Frame f, boolean m1, boolean m2 ) { this.m2 = m2; super( f,m1 ); // <<< COMPILER ERROR James ------------------------------------------------------------ The opinions expressed are my own and do not reflect those of my employer. ------------------------------------------------------------ From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!in1.uu.net!rssi.rssi.com!news Thu Mar 21 10:10:36 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!in1.uu.net!rssi.rssi.com!news From: John Zukowski Newsgroups: comp.lang.java Subject: Re: Help -- wait(), notify Date: Fri, 15 Mar 1996 11:17:23 -0500 Organization: Rapid Systems Solutions Message-ID: <31499813.7173@rssi.com> NNTP-Posting-Host: 198.3.220.197 Yongsong Liu wrote: > > hi: > can anybody tell me how exactly wait(), and notify() works ? and what is > this thing called monitor? where can i find detailed information about > them ? > > i wrote some code to see how they works, the thread that calls wait() > wakes up without any notify(). why is that ? > > thank you !! > > ////////////////////////////////////////// > > class singleThread extends Thread > { > int num; > > singleThread( int num ) > { > this.num = num; > } > > public void run() > { > System.out.println( "Thread " + num + " started and wait..." > ); > try{ > wait(); > } catch( Exception e ){} > > System.out.println( "Thread " + num + " wake up"); > System.out.println( "Thread " + num + " stop" ); > } > } > > public class test > { > public static void main( String arg[] ) > { > singleThread [] threads = new singleThread[4]; > int i = 0; > > System.out.println( "create thread " + i ); > threads[i] = new singleThread( i ); > threads[i].start(); > try{ > Thread.sleep( 7000 ); > } catch( Exception e ){} > > threads[i].notify(); > } > } > > ////////////////////////////////////////// > > the output look like this........ > > created thread 0 > Thread 0 started and wait... > Thread 0 wake up > Thread 0 stop > java.lang.IllegalMonitorStateException: current thread not owner > at trywait2.main(trywait2.java:50) wait/notify are really only useful in synchronized blocks. By calling wait, you are letting someone else who is synchronized run. They would then need to call notify to let you continue. Really simple. :-) John Zukowski Rapid Systems Solutions http://www.rssi.com john.zukowski@rssi.com From csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!tube.news.pipex.net!pipex!plug.news.pipex.net!pipex!rocannon.cam.harlequin.co.uk!markt Thu Mar 21 10:11:02 1996 Path: csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!tube.news.pipex.net!pipex!plug.news.pipex.net!pipex!rocannon.cam.harlequin.co.uk!markt From: markt@harlqn.co.uk (Mark Tillotson) Newsgroups: comp.lang.java Subject: Re: Help -- wait(), notify Date: 15 Mar 96 19:29:46 GMT Organization: Harlequin Limited, Cambridge, England Message-ID: NNTP-Posting-Host: atlas In-reply-to: John Zukowski's message of Fri, 15 Mar 1996 11:17:23 -0500 > wait/notify are really only useful in synchronized blocks. By calling ^^^^^^^^^^^^^^^^^^ > wait, you are letting someone else who is synchronized run. They would > then need to call notify to let you continue. Really simple. :-) The requirement is more stringent than that, you are _obliged_ to use wait(), notify() and notifyAll() __only__ on objects you currently have the monitor for.... The results are undefined if you don't. (For some reason Sun's implementation doesn't raise an IllegalThreadStateException for this ??) From java/lang/Object.java > * The method wait() can only be called from within a synchronized method. > * The method notifyAll() can only be called from within a synchronized method. > * The method notify() can only be called from within a synchronized method. Of course this isn't quite true, in that you can use them inside a method called from the synchronized method, or (dynamically) inside a "synchronized (thing) {}" block... __Mark [ markt@harlequin.co.uk | http://www.harlequin.co.uk/ | +44 1223 873829 ] [ homepage http://www.hal.com/services/juggle/home/markt@harlequin.co.uk/ ] PS Maybe I'm being naive, but why not read the documentation for a method before using it... From csus.edu!news.ucdavis.edu!library.ucla.edu!agate!howland.reston.ans.net!EU.net!Austria.EU.net!newsfeed.ACO.net!news.univie.ac.at!coil.mdy.univie.ac.at!gl Thu Mar 21 10:17:46 1996 Path: csus.edu!news.ucdavis.edu!library.ucla.edu!agate!howland.reston.ans.net!EU.net!Austria.EU.net!newsfeed.ACO.net!news.univie.ac.at!coil.mdy.univie.ac.at!gl From: gl@mdy.univie.ac.at (Gerald Loeffler) Newsgroups: comp.lang.java Subject: Re: enumeration type in C and any equivalence in java? Date: 18 Mar 1996 11:32:48 GMT Organization: Univ. of Vienna, Inst. for Theoretical Chemistry Message-ID: <4ijhl0$1n18@www.univie.ac.at> NNTP-Posting-Host: coil.mdy.univie.ac.at Keywords: enumeration Concerning a work-around for enums in JAVA: In article <4ii8l0$uri@motown.coast.net>, mouse@intranet.org (Chris Dailey) writes: |> In article <4icien$7q2@wsinti01.win.tue.nl>, |> Kees Huizing wrote: |> >>I am trying to convert some C code into java and having some trouble |> >>converting the enumeration type to java. |> ... |> >class Mood { |> > public static int HAPPY = 1; |> > public static int ANGRY = 2; |> >} |> > |> >class X { |> > int x1 = Mood.HAPPY; |> >} |> |> Of course, this destroys any hope of type checking, 'cause all of these |> things are just ints. You can assign any old int to one of these |> values. |> ... I agree: emulating enums in the way shown above is no better than using #defines in C for the same purpose: you don't get any runtime-checking! I usually use the following workaround: public final class MyEnum { private int v; private MyEnum(int value) {v = value;} public static final MyEnum ENUM_VAL_1 = new MyEnum(0); public static final MyEnum ENUM_VAL_2 = new MyEnum(1); public synchronized boolean equals(Object o) { if ((o instanceof MyEnum) && (((MyEnum) o).v == v)) return true; else return false; } } No MyEnum is a true type with the values MyEnum.ENUM_VAL_1 and MyEnum.ENUM_VAL_2 that can be used as follows (sorry, no switch, just if): public synchronized void doSomething(MyEnum e) { if (e.equals(MyEnum.ENUM_VAL_1)) { ... } else if (e.equals(MyEnum.ENUM_VAL_2)) { ... } } and then call doSomething() _only_ as doSomething(MyEnum.ENUM_VAL_1); or as doSomething(MyEnum.ENUM_VAL_2); Maybe one could even factor the int member and the equals() method from all enums into a common base class Enum, such that creating a new enum just means subclassing from Enum and defining the class-constants... Gerald -- Gerald Loeffler PhD student in Theoretical Biochemistry EMail: Gerald.Loeffler@mdy.univie.ac.at Phone: +43 1 40480 612 Fax: +43 1 4028525 SMail: University of Vienna Institute for Theoretical Chemistry Theoretical Biochemistry Group Waehringerstrasse 17/Parterre A-1090 Wien, Austria From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!dimensional.com!winternet.com!news Fri Mar 22 06:32:23 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!dimensional.com!winternet.com!news From: George Reese Newsgroups: comp.lang.java Subject: Re: java Vector troubles Date: Fri, 15 Mar 1996 22:06:50 -0600 Organization: Nightmare LPMud (nightmare.imaginary.com 1701) Message-ID: <314A3E5A.5CC8@imaginary.com> NNTP-Posting-Host: delos.imaginary.com You specifically need to implement the equals() method in your Record class, otherwise the Vector class has no criteria of equality that makes sense with an object it does not know. Daniel Farfan wrote: > > Anybody out there using Vectors? > > I'm having trouble making "contains" find a instance in the > vector. > > Here's the scenario: > > Create a vector like so: > > protected Vector record = new Vector(40,5); > ... > > then fill it up a bit from a data file (or whereever): > > record.addElement(new Record("123,456",10)); > [note: constants shown here going to the constructor for brevity) > ... > > get some input from somewhere else: > String s = "123,456"; > int num = 10; > ... > > make a record out of it > > Record myRec = new Record(s,num); > > ... > then (finally) see if record "contains" it. > > if ( record.contains(myRec) ) > System.out.println("celebrate!"); > else > System.out.println("cry."); > > But it's never there. > > Is contains using the memory address or something else > rather than comparing the two items? The memory address of > myRec and what's been addElement-ed would certainly > be different. > > If contains *can't* be made to do this, I'm wondering > what good it is? -- George Reese (borg@imaginary.com) http://www.imaginary.com/~borg i think i've reached that point/where every wish has come true/ and tired disguised oblivion/is everything i do -the cure From csus.edu!news.ucdavis.edu!agate!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!news.cis.okstate.edu!news.ksu.ksu.edu!news.physics.uiowa.edu!math.ohio-state.edu!usc!howland.reston.ans.net!newsfeed.internetmci.com!usenet.eel.ufl.edu!news-feed-1.peachnet.edu!paperboy.wellfleet.com!news3.near.net!shore!northshore.shore.net!ikrakow Fri Mar 22 06:50:45 1996 Path: csus.edu!news.ucdavis.edu!agate!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!news.cis.okstate.edu!news.ksu.ksu.edu!news.physics.uiowa.edu!math.ohio-state.edu!usc!howland.reston.ans.net!newsfeed.internetmci.com!usenet.eel.ufl.edu!news-feed-1.peachnet.edu!paperboy.wellfleet.com!news3.near.net!shore!northshore.shore.net!ikrakow From: ikrakow@shore.net (Ira Krakow) Newsgroups: comp.lang.java Subject: Java-Digest - Independent Java Mailing List Date: 17 Mar 1996 03:11:41 GMT Organization: Shore.Net/Eco Software, Inc; (info@shore.net) Message-ID: <4ifvtd$fqm@shore.shore.net> NNTP-Posting-Host: northshore.shore.net Java Digest (java-digest) "Your Source for All Things Java" Java-digest is an independent electronic magazine for anyone who is interested in the Java language - the hottest language on the Internet! It is an interactive interchange of information on new developments in Java, including: o Java tips, tricks, and traps o utilities and Java programming environments o Java-enabled browsers o Java-enabled Internet servers o Comparing Java to other languages o Integrating Java with databases o Useful applets o Useful standalone applications o "Where is Java going?" ...and anything else you'd like to discuss related to Java... I am an *independent* database and Internet consultant, who has absolutely no connections with Sun Microsystems (the developers of Java). This is an open forum where anyone is free to speak their mind. I believe that an independent forum such as this is the fastest way to exchange information on this constantly evolving and ever changing language. I publish java-digest in digest form only. I receive all the e-mails directed to the digest, assemble them in digest form, and send the digest out when traffic warrants. In this way, I cut down the noise on the list and group the messages by topic, which improves the magazine's readability. In addition, this cuts down network traffic and lessens your e-mail load (you get one big e-mail instead of many small ones). There's no charge for subscribing. However, if you believe the information is worthwhile to you, I ask a $20/year subscription fee. I do not discriminate either in favor of paid subscribers or against non-paying subscribers. Everyone can join the discussion. ------------------------------------------------------------------ TO SUBSCRIBE: Send an email note to: majordomo@shore.net The text of the email should read: subscribe java-digest That's all you need. The subject is ignored, as is everything except "subscribe java-digest". ------------------------------------------------------------------ My name is Ira Krakow and I'm the "publisher". I have extensive experience in all sorts of computer languages - from mainframe COBOL to C, C++, Visual Basic, PowerBuilder, RPGII, -- you name it, I've probably programmed in it. I also develop custom databases for companies, principally in Microsoft Access, SQL Server, and Advanced Revelation. I set up java-digest to help me get timely information on Java-related developments. I hope it can help you keep up as well. I welcome all comments and hope this magazine will develop over time, thanks to your input. Please send e-mail to: ikrakow@shore.net. From csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!swrinde!newsfeed.internetmci.com!in1.uu.net!news.nevada.edu!news.tamu.edu!tam2000!acc4636 Fri Mar 22 06:58:56 1996 Path: csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!swrinde!newsfeed.internetmci.com!in1.uu.net!news.nevada.edu!news.tamu.edu!tam2000!acc4636 From: acc4636@tam2000.tamu.edu (Anthony C.) Newsgroups: comp.lang.java Subject: Re: 'System.out.println' doesn't work: Has anyone else not found this ?? Date: 18 Mar 1996 15:24:52 GMT Organization: Texas A&M University, College Station Message-ID: <4ijv84$5lt@news.tamu.edu> NNTP-Posting-Host: tam2000.tamu.edu In article <314D6366.6BBF@easynet.co.uk>, Shaun Mitchem wrote: :Running applets with Netscape 2.0 (final version) and win95, none which :contain a 'System.out.println("...")' statement actually print the line, :so for example, the first applet in 'Teach Yourself java in 21 days'. :Where one uses fonts and graphics it is o.k but no basic print :statements, why is that, does anyone know ?? Well the graphics stuff is specific graphics context, what graphics context would a system.out.println print on? Try opening the java console under options, and your println output will be there. -- Anthony C. From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!metro!metro!unsw.edu.au!avip Fri Mar 22 07:16:51 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!metro!metro!unsw.edu.au!avip From: avip@cse.unsw.edu.au (Avi Pilosof) Newsgroups: comp.lang.java Subject: Re: Array Will Crash Your Computer Date: 20 Mar 1996 21:57:14 GMT Organization: University of New South Wales Message-ID: <4ipuvq$osv@mirv.unsw.edu.au> NNTP-Posting-Host: boodle.circus.cse.unsw.edu.au X-Newsreader: TIN [version 1.2 PL2] Barry Krusch (bak@netcom.com) wrote: : public void paint(Graphics g) : { : char array[] = new char [10]; : : array = "Hello"; : g.drawString (array[0], 25, 50); : } For one thing, I'd expect it to be: g.drawString( array, x, y ); Not "array[0]". "array[0]" is a character, not a string. Then again, perhaps you should just declare "array" as a string: String array = "Hello". ################################################################### Avi Pilosof - avip@cse.unsw.edu.au - http://www.cse.unsw.edu.au/~avip/ > Crime wouldn't pay if the government ran it. From csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!newsfeed.internetmci.com!ncar!csn!news-1.csn.net!csn!nntp-xfer-2.csn.net!magma.Mines.EDU!news Fri Mar 22 07:18:24 1996 Path: csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!newsfeed.internetmci.com!ncar!csn!news-1.csn.net!csn!nntp-xfer-2.csn.net!magma.Mines.EDU!news From: drferrin@onyx.Mines.EDU (Danno Ferrin) Newsgroups: comp.lang.java Subject: Re: pointers to functions in java Date: 21 Mar 1996 18:03:37 GMT Organization: Colorado School of Mines Message-ID: <4is5lp$lk8@magma.Mines.EDU> Reply-To: drferrin@mines.edu NNTP-Posting-Host: onyx.mines.edu In article <314F1DA0.609E@discover.wright.edu> CHETANKUMAR PATEL writes: > Hi, > I am converting a simulation package from C++ & Motif to Java. > I have a pointer to a class member function. What the program does, is > that it passes a pointer to a method in a subclass at run-time. This > method reference is then typecast to the pointer to call the appropriate > method. This is being done because the method to be called is not known > until run-time & since it may or may not be a method in the base class. > > > Can somebody tell me, how this above problem can be solved in Java. > Basically I would like to know how to define the equivalent of a pointer > to a member function in Java. It is very diffrent that might be expected, but it can be done after a fashion. You would need to define an interface that defines the function signature: interface SimpleFunction { // interface for a function f(x) public double f(double x); }; You would then define a clatt that implements it class Exponential implements SimpleFunction { public double f(double x) { int return = 0; for (int i = 1; i < 20; i++) return += x / MyMath.factorial(i) // probobly wrong! }; }; Then for the "member function pointer" you would have a variable SimpleFunciton myf; and to get the pointer you would get the refrence to myfunc. There is no ->* or .* operators, as there would be a security threat. Also methods cannot be taken out of context of the class that defined them, unlike c++. --Danno Colorado School of Mines -- undergraduate CS From csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!newsfeed.internetmci.com!in2.uu.net!taurus.bv.sgi.net!usenet Fri Mar 22 07:36:15 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!newsfeed.internetmci.com!in2.uu.net!taurus.bv.sgi.net!usenet From: David Chancellor Newsgroups: comp.lang.java Subject: NEWBIES - Fix the problem - Watch the filename !!! Date: Thu, 21 Mar 1996 21:58:32 -0500 Organization: Stargate Industries, Inc. Message-ID: <31521758.2C7E@sgi.net> NNTP-Posting-Host: dialup18.pgh.sgi.net I ran into this in the beginning too... I have seen a number of people struggling with it - This is from somebodies problem message... In c:\testcode\applet, I create a file called helloWorld.java I compile it and get the following error. helloapplet.java:5: Warning: Public class HelloApplet must be defined in a file called "HelloApplet.java". public class HelloApplet extends java.applet.Applet { ^ 1 error ... The file MUST be called HelloApplet.java - not HelloWorld.java it seems crazy when you are used to independence from the actual filename - but its the truth... From dick Thu Mar 21 10:08 PST 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!newsfeed.internetmci.com!panix!news.columbia.edu!watsun.cc.columbia.edu!pavel From: pavel@watsun.cc.columbia.edu (Pavel Matsibekker) Newsgroups: comp.lang.java Subject: Re: Any Clever Solution to the Following Problem? Date: 19 Mar 1996 21:19:41 GMT Organization: Columbia University Message-ID: <4in8dd$ega@apakabar.cc.columbia.edu> NNTP-Posting-Host: watsun.cc.columbia.edu In article <3145B8B4.2108@ccm.jf.intel.com>, Patrick Logan wrote: >Darin Warling wrote: >> >> Basically, I want to store objects of any arbitrary class in a vector and >> then retrieve them and automatically transform them back into their >> original class without having to code in an explicit cast for each one. >> ... >> I know I can explicitly cast the type using >> Integer i = (Integer)o; >> but I don't want to (or can't) do this for a number of reasons. > >Then *please* show us in psuedo-Java what it is you'd like to do! > >> I can still retrieve the object's original class using >> Class c = o.getClass(); >> System.out.println( c.toString() ); >> which returns >> class java.lang.Integer >> >> It seems like the system maintains enough information to do automatic >> casting, but I can't for the life of me figure out a way to do it. Maybe >> through Object methods, Class methods, or ClassLoader methods? Any ideas? > >What the heck does it mean to do an "automatic cast" in a statically >typed language??? > >Whenever you actually want to use the Object as an object of a subclass, >you have to name the class to use!!! > > >-- >mailto:Patrick_D_Logan@ccm.jf.intel.com >(503) 264-9309, FAX: (503) 264-3375 > >"Poor design is a major culprit in the software crisis... >...Beyond the tenets of structured programming, few accepted... >standards stipulate what software systems should be like [in] detail..." >-IEEE Computer, August 1995, Bruce W. Weide I know exactly what you're talking about. I tried to do the same thing and I got a negative response. However, depending on what you want to do, it is possible to get around it. I derived all classes that I think would be put into the Vector from a Base Class. I'm assuming that functionality of derived classes would be similar such that (for example) after you extract them from the Vector class you would call doSomething(). This method would be defined in the base class and overload in each derivation to do whatever it is you want your individual classes to do. I even got it to do the following class Base{ Base() .... doSomething (){ Base b=new Base(); b=(Base) this; b.doNothing(); } doNothing() {}; } class Derived extends Base{ Derived () {...}; doSomething(){ Derived d= new Derived(); d=(Derived) this; d.doSomethingElse(); } doSomethingElse() { println( "this is a method Base does not have"); } } Ok, so if you put this in a vector class...pop it up and cast it to class (Base)....however the way java works is that the doSomething method is virtual(at least that's what it seems to be) and the derived definition of doSomething will be run. The only thing that I see that this can't do is return a value back to the top, except in the case where you know it will always be the same type no matter the derivation. I hope you got an idea of what I'm talking about. It's not templates, but templates are dangerous in C++ anyway. You make do. pavel From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!agate!howland.reston.ans.net!nntp.crl.com!newshub.cts.com!alpha.sky.net!winternet.com!news1.io.org!else.net!innuendo.tlug.org!clio.trends.ca!worldlinx.com!news1.sympatico.ca!news Mon Mar 25 06:30:38 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!agate!howland.reston.ans.net!nntp.crl.com!newshub.cts.com!alpha.sky.net!winternet.com!news1.io.org!else.net!innuendo.tlug.org!clio.trends.ca!worldlinx.com!news1.sympatico.ca!news From: Chuck Burns Newsgroups: comp.lang.java Subject: Re: Class not Found Errors Date: Wed, 13 Mar 1996 08:29:25 -0500 Organization: Sympatico Message-ID: <3146CDB5.7429@sympatico.ca> NNTP-Posting-Host: ppp2374.on.sympatico.ca Aaron S. Carmichael wrote: > > So once again I am going to ask if anyone has an answer (I sure it is > real simple) to why when accessin my host I my classes cannot be > found. > > They are all in the propper context and also in the proper case. I > have gotten some replies telling me to check that and I have over and > over again. > > I can view and load and run all the applets from my own system on my > page without a problem. It is when i try to access exactly the same > page just on the unix host that it does not work.. > > Any suggestions??? > I had the same problem, classes would load locally, but not from a server. I fixed it as follows: I reviewed all classes that were instantiated within the class that was not found. I added constructor methods in those classes, even tho I never directly call the constructors. For unknown reasons, the problem then went away. Hope this helps you. e.g. import java.awt.*; public class CTGraphicButton extends Canvas() { CTGraphicButton() {} //I had to add this even tho i never call it. ... } import java.awt.*; public class CTToolbarButton extends CTGraphicButton { CTToolbarButton() {} // same thing here. ... } From csus.edu!tns.sdsu.edu!ucsnews!sol.ctr.columbia.edu!spool.mu.edu!howland.reston.ans.net!swrinde!news-relay.us.dell.com!jump.net!not-for-mail Mon Mar 25 07:08:04 1996 Path: csus.edu!tns.sdsu.edu!ucsnews!sol.ctr.columbia.edu!spool.mu.edu!howland.reston.ans.net!swrinde!news-relay.us.dell.com!jump.net!not-for-mail From: greg@vignette.com (Greg Hilton) Newsgroups: comp.lang.java Subject: Bug in java.util.Properties.java Date: 22 Mar 1996 23:18:58 GMT Organization: Jump Point Communications, Inc. Message-ID: <4ivch2$m04@news.jump.net> NNTP-Posting-Host: 207.8.8.5 X-Newsreader: TIN [UNIX 1.3 950824BETA PL0] Anyone is using the Properties class in JDK-1.0, should be aware of the following bug in the "load" method: Lines 92-100 which read: 92: while ((ch == ' ') && (ch == '\t')) { 93: ch = in.read(); 94: } 95: if ((ch == '=') || (ch == ':')) { 96: ch = in.read(); 97: } 98: while ((ch == ' ') && (ch == '\t')) { 99: ch = in.read(); 100: } should read: 92: while ((ch == ' ') || (ch == '\t')) { 93: ch = in.read(); 94: } 95: if ((ch == '=') || (ch == ':')) { 96: ch = in.read(); 97: } 98: while ((ch == ' ') || (ch == '\t')) { 99: ch = in.read(); 100: } Note the use of || rather than && in lines 92 and 98. The class the way it is originally written incorrectly handles whitespace around the '=' or ':' characters. I have report this to java-bugs but, of course, the known bug list has not been updated. Greg -- ...................................................... : Greg Hilton : greg@vignette.com : Austin, : : Vignette Corporation : (512)502-0223 x12 : Texas : :......................:...................:.........: From csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!nntp.club.cc.cmu.edu!cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!howland.reston.ans.net!Germany.EU.net!wizard.pn.com!sundog.tiac.net!NewsWatcher!user Mon Mar 25 07:14:19 1996 Path: csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!nntp.club.cc.cmu.edu!cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!howland.reston.ans.net!Germany.EU.net!wizard.pn.com!sundog.tiac.net!NewsWatcher!user From: axlrosen@tiac.net (Alex Rosen) Newsgroups: comp.lang.java Subject: Re: Please ask before taking someone's applet! Date: Sun, 24 Mar 1996 14:59:54 -0500 Organization: The Internet Access Company Message-ID: NNTP-Posting-Host: axlrosen.tiac.net >I think the only protection is to include a visible >copyright notice in your *running* applet, and not merely in your source >(which is not downloaded). I don't like that solution, but I don't know >of any more attractive alternative. A while ago someone mentioned a clever safegaurd: call getDocumentBase and/or getCodeBase, and refuse to run if they don't match your home page. In any case, from my (extremely limited) knowledge of US copyright law, I believe that anything you write is automatically copyrighted by you, even without a copyright notice. I know this applies to stories, novels, etc., I assume it applies to programs as well. Alex Rosen http://www.tiac.net/users/axlrosen/ From csus.edu!news.ucdavis.edu!library.ucla.edu!nntp.club.cc.cmu.edu!cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!in1.uu.net!alterdial.uu.net!not-for-mail Mon Mar 25 07:15:49 1996 Path: csus.edu!news.ucdavis.edu!library.ucla.edu!nntp.club.cc.cmu.edu!cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!in1.uu.net!alterdial.uu.net!not-for-mail From: Chuck McManis Newsgroups: comp.lang.java Subject: Re: Please ask before taking someone's applet! Date: Sun, 24 Mar 1996 17:54:46 -0800 Organization: GolfWeb Inc. Message-ID: <3155FCE6.ED4@golfweb.com> NNTP-Posting-Host: 206.137.228.10 Alex Rosen wrote: [ please don't steal my applets. ] Alex is completely correct. Applets are not "freeware" unless explicitly stated as such. (Just like .gif images aren't free) As applets become more popular this will be more of an issue. Fortunately one can hunt down the more stupid pirates by using http://altavista.digital.com Go to advanced search and type: applet: YourAppletName.class and see all of the web pages that have your applet on them. --Chuck From csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!nntp.coast.net!zombie.ncsc.mil!news.mathworks.com!newsfeed.internetmci.com!athos.itribe.net!bagpipes.itribe.net!bianco Mon Mar 25 07:16:56 1996 Path: csus.edu!news.ucdavis.edu!agate!howland.reston.ans.net!nntp.coast.net!zombie.ncsc.mil!news.mathworks.com!newsfeed.internetmci.com!athos.itribe.net!bagpipes.itribe.net!bianco From: David J. Bianco Newsgroups: comp.lang.java Subject: Re: Please ask before taking someone's applet! Date: 25 Mar 1996 13:32:07 GMT Organization: iTribe, Incorporated Message-ID: <31557A89.2543@BlueSky.net> <4j5lse$drt@newsy.ifm.liu.se> NNTP-Posting-Host: gatekeeper.itribe.net In-reply-to: rickard@lysator.liu.se's message of 25 Mar 1996 08:35:26 GMT In article <4j5lse$drt@newsy.ifm.liu.se> rickard@lysator.liu.se (Rickard Öberg) writes: || || Shouldn't it be possible to use the getCodeBase() method and compare the || codebase servername part with the server name where it is intended to run. || Then if the wo differs just don't start the applet. Maybe also throw en || exception like: PirateException("Die, you pirating bastard!"); || It should work.. :-) || Yup, this works just fine. I've gone a step beyond that in my applets. I wrote a set of license key functions that I include in any applet that needs them (unfortunately, they can't be a separate class for security reasons). In my HTML code, I can specify a license key, which my applet will check. It's more flexible than just checking the code base, since it lets me give my applet to licensed parties, and even include an expiration date. -- ========================================================================== David J. Bianco | Web Wonders, Online Oddities, Cool Stuff iTRiBE, Inc. | Phone: (804) 446-9060 Fax: (804) 446-9061 Suite 1700, World Trade Center | email: Norfolk, VA 23510 | URL : http://www.itribe.net/~bianco/ From csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!europa.chnt.gtegsc.com!news.kreonet.re.kr!news.nuri.net!imci2!news.internetMCI.com!newsfeed.internetmci.com!in1.uu.net!winternet.com!alpha.sky.net!solar.sky.net!not-for-mail Mon Mar 25 07:22:43 1996 Path: csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!europa.chnt.gtegsc.com!news.kreonet.re.kr!news.nuri.net!imci2!news.internetMCI.com!newsfeed.internetmci.com!in1.uu.net!winternet.com!alpha.sky.net!solar.sky.net!not-for-mail From: williams@solar.sky.net (Eric Williams) Newsgroups: comp.lang.java Subject: Re: Java Exceptions: Sun broke them. Way to go! Date: 24 Mar 1996 00:19:30 -0600 Organization: SkyNET Online Message-ID: <4j2phi$2tm@solar.sky.net> NNTP-Posting-Host: solar.sky.net In article <4j2cr3$he0@hopi.gate.net>, Sean 'Captain Napalm' Conner wrote: > [...] > > Okay, so I uncomment the throws clause, I now get: > >myLayout.java:19: Invalid exception class myClass.myException in throws > clause. The exception must be a subclass of an exceptoin thrown by > void addLayoutCompoment(java.lang.String, java.awt.Compoment) from > interface java.awt.LayoutManager. > public void addLayoutComponent(String name,Component comp) throws > myException > ^ >1 error > > What? First off, java.awt.LayoutManager doesn't throw ANY exceptions, nor >is there a way to return an error indication (how convenient that the >addLayoutComponent() is declared as void). For the application I'm writing, >NOT returning an error code when adding to a region that is not supported by >my layout manager is NOT an option. And declaring a public variable to check >after each call to add() is again, not an option (why have exceptions then? >At that point, all I've done is implimented the functionality of C's errno. >This is progress?). > > So, it seems that I can't even raise my own exceptions to take up the lack >of error checking in parts of the AWT. Previously I've caught a few potential >bugs this way (mostly typos). Now even that is taken away from me. So much >for reliable code. Way to go Sun! Woo hoo! > > I have no problem with having to declare a throws clause for each type of >exception that can occure. I just want the ability to throw my own. You make some good points. Here's what's going on, and how to get around it. [I'm not going to touch the question of whether it should or shouldn't be this way, because I'd like to think for a while before having an opinion on this issue.] 1. The error message is brain-dead. It should tell you that you can't declare a 'throws' clause in this method. 2. You can't declare a 'throws' clause in this method because the 'throws' clause is part of the type-signature of the method, and LayoutManager.addLayoutComponent() is not declared to throw any exceptions. [It's the same thing with some modifier flags, like 'synchronized'.] 3. You *can* throw an exception in this method if the exception class happens to be RuntimeException, or a subclass thereof. You don't have to declare a 'throws' clause for these kinds of exceptions. From csus.edu!news.ucdavis.edu!agate!news.ossi.com!netserv.com!news.mathworks.com!news.kei.com!sundog.tiac.net!usenet Thu Mar 28 10:26:15 1996 Path: csus.edu!news.ucdavis.edu!agate!news.ossi.com!netserv.com!news.mathworks.com!news.kei.com!sundog.tiac.net!usenet From: Jeff Sutherland Newsgroups: comp.lang.java,comp.lang.c++,comp.lang.smalltalk Subject: Re: Will Java kill C++? Date: Tue, 26 Mar 1996 12:32:53 -0500 Organization: VMARK Software Message-ID: <31582A45.3742@vmark.com> NNTP-Posting-Host: jsuth.tiac.net CC: jsutherland@vmark.com Xref: csus.edu comp.lang.java:34820 comp.lang.c++:172716 comp.lang.smalltalk:34457 RjB wrote: > > >Java is here to stay and is moving forward at a pace the Smalltalk > >market can't even comprehend. So quit whining about how Smalltalk can > >do all the things Java can do. No one cares about Smalltalk! > > > > Aside from the flamebait, I'm just wondering if any > systems have been built in Java of sizes approaching those built in > Smalltalk. Because, to my mind, it's really when you're > programming-in-the-humungous that development systems prove > themselves. > > -rj > -- > onomoto -- 555 | Infoto Diegoto DODOTO Tobagoto vetoto Texacoto > bryant st #136 palo | > alto ca 94301 | Kyototo Oronoto Orinocoto vivoto GINKGOTO. Systems the size of many large Smalltalk systems have not begun to be built in Java. The guys at Sun will tell you its not ready for prime time yet. They would like to deescalate the hype a little bit. Java doesn't even have a modern garbage collector and its performance is terrible, 10-30 times slower than C. Borland intends to fix this before year's end. There is a benchmark in this month's Smalltalk Report showing how a Smalltalk application can be tuned to run *faster* than C. That said, there will be more compiler development going on in Java over the next few years than any other language, so it will eventually get there. I expect that many C++ programmers will begin to use Java as an application language with C++ seamlessly interfaced as the object-oriented assembler, which is what it was designed for in the first place. The beauty of Java is that it is Smalltalk for C++ programmers. We need it. -- Jeff Sutherland mailto:jsutherland@vmark.com http://www.tiac.net/users/jsuth/ "Surf first and ask questions later!" From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!ringer.cs.utsa.edu!news.cais.net!news.ac.net!imci4!newsfeed.internetmci.com!news.mathworks.com!zombie.ncsc.mil!admaix.sunydutchess.edu!ub!newsstand.cit.cornell.edu!news.consultix.com!news1.noc.netcom.net!noc.netcom.net!news4.noc.netcom.net!symiserver2.symantec.com!usenet Thu Mar 28 10:29:09 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!ringer.cs.utsa.edu!news.cais.net!news.ac.net!imci4!newsfeed.internetmci.com!news.mathworks.com!zombie.ncsc.mil!admaix.sunydutchess.edu!ub!newsstand.cit.cornell.edu!news.consultix.com!news1.noc.netcom.net!noc.netcom.net!news4.noc.netcom.net!symiserver2.symantec.com!usenet From: sdeeg@symantec.com (Scott Deeg) Newsgroups: comp.lang.java Subject: Re: Maybe It's Me Date: 21 Mar 1996 19:08:31 GMT Organization: Symantec Message-ID: <4is9ff$7hc@symiserver2.symantec.com> NNTP-Posting-Host: 155.64.36.127 X-Newsreader: Cyberjack News 7.00 In article , bak@netcom.com (Barry Krusch) wrote: > I don't know. All I want to do is print out the letter "H". Instead, I > get a "[] can only be applied to arrays" message when I want to compile > this snippet: > > public void paint(Graphics g) > { > String messages [] = new String [10]; > > messages [0] = "Hello"; > > g.drawString (messages[0][0], 25, 50); <== THE OFFENDER!! > } Barry, Strings in Java are not the same as they are in C. You can't treat an array of characters as a string. (Or an array of Strings as an array of characters.) Above, what you did was create an array of 10 references to the class String. What you want is: String messages = "Hello"; g.drawString(messages.subString(0,0), 25, 50); //or some such thing as this happy programming, Scott Deeg From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!news.dacom.co.kr!news.uoregon.edu!symiserver2.symantec.com!usenet Thu Mar 28 10:29:26 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!news.dacom.co.kr!news.uoregon.edu!symiserver2.symantec.com!usenet From: sdeeg@symantec.com (Scott Deeg) Newsgroups: comp.lang.java Subject: Re: Maybe It's Me Date: 22 Mar 1996 22:09:32 GMT Organization: Symantec Message-ID: <4iv8es$b29@symiserver2.symantec.com> NNTP-Posting-Host: 155.64.36.127 X-Newsreader: Cyberjack News 7.00 In article , bak@netcom.com (Barry Krusch) wrote: > This doesn't work either: > > g.drawString(messages[0].charAt(0), 25, 50); > > drawString doesn't support it. > Barry, The correct call is: g.(message[0].substring(0,1), 25, 50); happy programming Scott Deeg From csus.edu!csulb.edu!drivel.ics.uci.edu!news.claremont.edu!kaiwan.kaiwan.com!news.uoregon.edu!symiserver2.symantec.com!usenet Thu Mar 28 10:33:20 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.claremont.edu!kaiwan.kaiwan.com!news.uoregon.edu!symiserver2.symantec.com!usenet From: sdeeg@symantec.com (Scott Deeg) Newsgroups: comp.lang.java Subject: Re: Arrays in Java Date: 21 Mar 1996 01:59:08 GMT Organization: Symantec Message-ID: <4iqd5c$ts@symiserver2.symantec.com> NNTP-Posting-Host: 155.64.36.127 X-Newsreader: Cyberjack News 7.00 In article <31500E05.41C6@reading.sgi.com>, Graham Russell wrote: > How can I declare and initialise a 2D array of a user defined type? I have > tried (as shown below), but the array is not initialised correctly. > > The declaration looks like this:- > > private Cell array[][]; > > and the initialisation looks like this:- > > array = new Cell[10][10]; Graham, When you do what you call initialization, what you are actually doing is creating an array of references (not instantiating new instances of Cell). You still need to actually call the constructor. i.e.: array[0][0] = new Cell(); This instantiates a new Cell and assigns it to the reference in the array at 0,0. My guess is that you will be able to figure it out from here. happy programming, Scott Deeg From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cssun.mathcs.emory.edu!gatech!newsfeed.internetmci.com!in1.uu.net!news3.digex.net!digex.net!not-for-mail Tue Apr 2 08:28:08 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cssun.mathcs.emory.edu!gatech!newsfeed.internetmci.com!in1.uu.net!news3.digex.net!digex.net!not-for-mail From: engel@access1.digex.net (Joshua Engel) Newsgroups: comp.lang.java Subject: Re: Enums && Java Date: 28 Mar 1996 19:27:30 -0500 Organization: Express Access Online Communications, Greenbelt, MD USA Message-ID: <4jfapi$crb@access1.digex.net> NNTP-Posting-Host: access1.digex.net In article <3151822D.167E@reading.sgi.com>, Graham Russell wrote: >This may sound like a stupid question and I may have missed the point, >but does >Java support enumerated types (like C and C++)? I don't think it does. > Directly, no, it doesn't. But here's a better alternative, one with type safety. Use a class to represent your types, and each element of your enum can be an instance of that class. Like so: public class IceCream { public static final Flavor CHOCOLATE = new Flavor(); public static final Flavor VANILLA = new Flavor(); public void addScoop(Flavor flav) { if(flav == CHOCOLATE) { // Add a scoop of chocolate } else if(flav == VANILLA) { // Add a scoop of vanilla } } public Flavor mostPopularFlavor() { return VANILLA; } } class Flavor { } You can use the class as follows: public class SodaJerk { public void dishItOut() { IceCream dessert = new IceCream(); dessert.addScoop(dessert.mostPopularFlavor()); dessert.addScoop(dessert.CHOCOLATE); } } You know a few things: CHOCOLATE is guaranteed to be different from VANILLA (i.e. CHOCOLATE != VANILLA). It can't be spoofed by somebody guessing the values. It's type safe, it involves very little code, and you can override methods (like toString) in your enumerated class for easy printing. So it costs a few bytes and a few nanoseconds; this isn't exactly microcode you're writing. Note that SodaJerk can't actually possess a member of type Flavor; the class is not public. You could make it public if you wanted, but then you'd have to stick it in its own file. Alternatively, the SodaJerk could assign IceCream.CHOCOLATE to an Object; the type safety will hold because the Object still knows its real type. Thanks to Bill Andersen of UMCP for showing me this. C ya. ------- Joshua Engel engel@access.digex.net From dick Thu Mar 28 11:12 PST 1996 From: dick (Dr. Richard Botting) Date: Thu, 28 Mar 1996 10:39:58 -0800 Message-Id: <199603281839.KAA28998@csci.csusb.edu> Subject: (fwd) WARNING: NEW SECURITY HOLE FOUND IN JAVA Newsgroups: comp.lang.java Organization: CS Dept., Calif. State Univ., San Bernardino Newsgroups: comp.lang.java Path: csus.edu!tns.sdsu.edu!hookup!solaris.cc.vt.edu!news.mathworks.com!news.kei.com!nntp.coast.net!col.hp.com!news.corp.hp.com!isonews.bbn.hp.com!news.sweden!hpwin055.uksr!hplb!news From: addy@mumble.hpl.hp.com (David Addison) Subject: WARNING: NEW SECURITY HOLE FOUND IN JAVA Message-ID: Date: Mon, 25 Mar 1996 10:33:09 GMT Nntp-Posting-Host: mumble.hpl.hp.com Organization: Hewlett-Packard Laboratories, Bristol, UK. Just saw this in comp.risks; --- Date: Fri, 22 Mar 1996 17:27:56 -0500 From: Ed Felten Subject: Java/Netscape security flaw We have discovered another serious security flaw in the Java programming language, which allows a malicious Java applet running under Netscape Navigator (version 2.0 or 2.01) to execute arbitrary machine code. We have implemented an applet that exploits the flaw to remove a file. Until a fix is issued, Netscape users can protect themselves by disabling Java in the Security Preferences dialog. At present we are not releasing technical details about the flaw. We will announce the full details later; some of the details will also appear in our upcoming paper in the proceedings of the IEEE Symposium on Security and Privacy, to be published in May. Our paper also contains an overall analysis of Java's security. For an advance copy of the paper, send mail to felten@cs.princeton.edu. The paper will be available in about a week. [Note that the "security enhancements" announced by Netscape in version 2.01 of Netscape Navigator do not fix this flaw. They fix two separate flaws found last month, one found by us (RISKS-17.77) and independently by Steve Gibbons, and the other found by David Hopwood (RISKS-17.83).] For more information, see http://www.cs.princeton.edu/~ddean/java, or contact Ed Felten at (609) 258-5906 or felten@cs.princeton.edu. Drew Dean, Ed Felten, Dan Wallach, Dept of Computer Science, Princeton Univ. ---- -- David Addison Hewlett-Packard Laboratories, NTD addy@hplb.hpl.hp.com Filton Road, Stoke Gifford, Bristol, BS12 6QZ Tel: +44 (0)117 922 9543 Fax: +44 (0)117 9228924 -- dick botting http://www.csci.csusb.edu/dick/signature.html Disclaimer: CSUSB may or may not agree with this message. Copyright(1996): Copy freely but say where it came from. I have nothing to sell, and I'm giving it away. From dick Thu Mar 28 11:27 PST 1996 From: dick (Dr. Richard Botting) Date: Thu, 28 Mar 1996 10:54:40 -0800 Message-Id: <199603281854.KAA17845@csci.csusb.edu> Subject: (fwd) Re: "cpu eaters" with java threads Newsgroups: comp.lang.java Organization: CS Dept., Calif. State Univ., San Bernardino Path: csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!newsfeed.internetmci.com!news.ac.net!news.cais.net!nntp.uio.no!ifi.uio.no!news.sics.se!news From: Jari Ojala Newsgroups: comp.lang.java Subject: Re: "cpu eaters" with java threads Date: Wed, 27 Mar 1996 16:53:13 +0100 Organization: Swedish Institute of Computer Science, Kista Message-ID: <31596469.6CD1@sics.se> NNTP-Posting-Host: 192.16.123.56 I forward this Ingo Wechsung's message: --cut here Subject: Re: "cpu eaters" with java threads Date: Wed, 27 Mar 1996 16:17:11 +0100 From: Ingo Wechsung Organization: CAS Nord GmbH To: Jari Ojala Jari Ojala wrote: > > My point was here that you *can't* stop the counter. I can use > your computer as a resource for my own private purposes. > The counter will continue as long your netscape process is running. > Eaven while you read other web pages or load other applets the > counter thread will stay on. I could use this bug/feature to > use your computer as a resource in my private > computations and you don't have any way to stop me.. :) > You are absolutely right. If I could post, I'd have done this, but unfortunately I am limited to read news only. Yesterday, I checked the number of threads netscape had before and after consulting some pages with applets. When I start a fresh copy of netscape, there are initially 3 threads. After only half an hour I had 18 threads, some of them still eating cpu. The bad thing is, that the browser user can't do anything about bad programming style (or intentional written unstopping applets). I think this is an area, where people should think again about an applets lifecycle. Please feel free to post this to comp.lang.java if you like. Ingo -- Email: iw@return-online.de Tel.: 07121/928624 Fax.: 07121/928686 CAS Nord GmbH, Geschaeftsstelle Reutlingen -- Return Online GmbH Friedrich-Ebert-Str. 3, 72762 Reutlingen, Germany Please have a look at our Web pages: http://www.return-online.de -- dick botting http://www.csci.csusb.edu/dick/signature.html Disclaimer: CSUSB may or may not agree with this message. Copyright(1996): Copy freely but say where it came from. I have nothing to sell, and I'm giving it away. From dick Thu Mar 28 11:32 PST 1996 From: dick (Dr. Richard Botting) Date: Thu, 28 Mar 1996 10:59:41 -0800 Message-Id: <199603281859.KAA17119@csci.csusb.edu> Subject: (fwd) New Java Security Hole Newsgroups: comp.lang.java Organization: CS Dept., Calif. State Univ., San Bernardino Path: csus.edu!csusac!charnel.ecst.csuchico.edu!waldorf.csc.calpoly.edu!decwrl!enews.sgi.com!lll-winken.llnl.gov!fnnews.fnal.gov!gw1.att.com!cnn.Princeton.EDU!usenet From: mpgordon@princeton.edu (Matt Gordon) Newsgroups: comp.lang.java Subject: New Java Security Hole Date: 27 Mar 1996 20:51:18 GMT Organization: Princeton University Message-ID: <4jc9o6$gme@cnn.Princeton.EDU> NNTP-Posting-Host: mpgordon.student.princeton.edu X-Newsreader: WinVN 0.99.3 Check out the latest on the new Java security hole discovered by Princeton researchers, by the same group that announced the DNS security hole last month. Read about it in The Princeton Spigot at . -- Matt Gordon | mpgordon@princeton.edu | http://www.princeton.edu/~mpgordon "All science is either physics or stamp collecting." Finger for PGP Key Visit -- dick botting http://www.csci.csusb.edu/dick/signature.html Disclaimer: CSUSB may or may not agree with this message. Copyright(1996): Copy freely but say where it came from. I have nothing to sell, and I'm giving it away. From csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!nntp.club.cc.cmu.edu!cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!udel!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!news.BSDI.COM!engr.orst.edu!holmes.ece.orst.edu!paul Wed Apr 3 07:41:12 1996 Path: csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!nntp.club.cc.cmu.edu!cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!udel!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!news.BSDI.COM!engr.orst.edu!holmes.ece.orst.edu!paul From: paul@holmes.ece.orst.edu (Paul Stoffregen) Newsgroups: comp.lang.java Subject: Re: Testing Applets with Netscape? Date: 3 Apr 1996 14:30:41 GMT Organization: Electrical and Computer Engineering, Corvallis Message-ID: <4ju22h$jqd@engr.orst.edu> NNTP-Posting-Host: holmes.ece.orst.edu Robert M. wrote: > >Does anyone know how to let netscape update the applet every time. (to >turn the internal cache of - to turn the memory cache off does not solve >the problem!) Did you try holding the shift key while you click on the reload button? Paul From hchilver@csci.csusb.edu Wed Apr 3 09:15 PST 1996 Message-Id: <3162A157.41C6@csci.csusb.edu> Date: Wed, 03 Apr 1996 08:03:35 -0800 From: Henry Chilvers Subject: Re: Mailing list? Dr. Richard Botting wrote: > > was_To: rwagner > was_Cc: dick, hyalaman, jstewart, paul, rlittle > > ...it would be good if we don't > all fight the same problems in parallel. I am willing > to act as a clearing house.... Include the > word Java in the title and I can redistribute it. > > Let me know if you are interested in being on a mailing list. I'm already signed up for a java mailing list. But if this one is different from the one that I am on, then I'll sign up for this one too. Here's the information about the list that I am subscribed to, feel free to sign up for this one, or pass it on to others: -- JAVA-WIN on majordomo@natural.com Java on Microsoft Windows JAVA-WIN-DIGEST on majordomo@natural.com The JAVA-WIN mailing list was formed in order to discuss software development using Sun Microsystem's Java language on the Microsoft Windows operating systems. Topics may range from discussion of tools, techniques, solutions, tech notes, and any other items of relevant interest to Windows Java developers. JAVA-WIN is an open, unmoderated, discussion list. Both the JAVA-WIN list and its digest version are distributed using Majordomo software. JAVA-WIN: To subscribe to JAVA-WIN, send the following command to majordomo@natural.com in the body of the email: SUBSCRIBE JAVA-WIN To unsubscribe to JAVA-WIN, send the following command to majordomo@natural.com UNSUBSCRIBE JAVA-WIN JAVA-WIN-DIGEST: Digest version of JAVA-WIN To subscribe to JAVA-WIN-DIGEST, the digest form of JAVA-WIN, send the following command to majordomo@natural.com in the body of the email: SUBSCRIBE JAVA-WIN-DIGEST To unsubscribe to JAVA-WIN-DIGEST, send the following command to majordomo@natural.com UNSUBSCRIBE JAVA-WIN-DIGEST Owner: Sandy Schneible java-mac-owner@natural.com ____________________________________________________________________ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ _/ Henry Chilvers, Gen. Man. hchilver@csci.csusb.edu _/ _/ Control C _/ _/ http://www.csci.csusb.edu/~hchilver/ _/ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ From csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!galaxy.ucr.edu!ihnp4.ucsd.edu!swrinde!cssun.mathcs.emory.edu!gatech!newsfeed.internetmci.com!news.texas.net!newsfeed.concentric.net!winternet.com!news Fri Apr 5 07:29:14 1996 Path: csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!galaxy.ucr.edu!ihnp4.ucsd.edu!swrinde!cssun.mathcs.emory.edu!gatech!newsfeed.internetmci.com!news.texas.net!newsfeed.concentric.net!winternet.com!news From: George Reese Newsgroups: comp.lang.java Subject: Re: Questions on Object Oriented Programming Date: Sun, 31 Mar 1996 22:43:17 -0600 Organization: Nightmare LPMud (nightmare.imaginary.com 1701) Message-ID: <315F5EE5.777B@imaginary.com> NNTP-Posting-Host: delos.imaginary.com Jason Lam wrote: > > Hello!! > > I got the following questions on Object Oriented Programming: > > What is a 'class' and an 'instance' of an object. Any examples? Basketball player is a class, and Michael Jordan is an instance. In other words, an instance is something real, a unique thing in the universe. A class is an abstraction of world objects. You cannot point to anything and say 'That is basketball player.' But you can point to Michael Jordan and say 'That is Michael Jordan.' Furthermore, you can point to him and say, 'Michael Jordan is a basketball player' which is really saying 'Michael Jordan is an instance of a basketball player.' > what is the state and behavior of an object each refer to. The state is simply a snapshot of its values at a given time. For a dog object, we might describe its state to be sleeping and not wagging its tail. Behaviour is simply whatever the object does. > What is a method? A method is a function. Specifically, a function that belongs to a class. > What is a 'message' is. Any example? A message is an abstract way of describing methods. Whenever you want an object to do something, you send a message. The message is made up of: who is receiving the message the name of the message any parameters to the message thus: dog.eat(alpo) is a message. > What two states can the button object "OPEN" in the Netscape toolbar > be in? This sounds like you are asking homework questions on the net :) I won't answer this one for that reason. The above questions, IMHO, are generally useful, and thus ok for me to answer. If I was successful with them, then you can answer this one yourself :) -- George Reese (borg@imaginary.com) http://www.imaginary.com/~borg i think i've reached that point/where every wish has come true/ and tired disguised oblivion/is everything i do -the cure From csus.edu!dick Fri Apr 5 08:00:17 1996 Path: csus.edu!dick From: dick@silicon.csci.csusb.edu (Dr. Richard Botting) Newsgroups: comp.lang.java Subject: arrrrrrgh: no local final anymore? Date: 5 Apr 1996 01:26:05 GMT Organization: California State University Sacramento Message-ID: <4k1srd$obf@news.csus.edu> NNTP-Posting-Host: dick%@orion.csci.csusb.edu X-Newsreader: TIN [version 1.2 PL2] We've just upgraded from a Fall 1995 Java compiler for Sun Sparc boxes to the Winter 96 release.... In the old one the following compiled: class Dummy1{ public void dumb(int i0, int j0){ final int n=j0+1-i0; } } Now it does not. tttt.java:2: Missing term. public void dumb(int i0, int j0){ ^ tttt.java:2: ';' expected. public void dumb(int i0, int j0){ ^ tttt.java:3: Invalid expression statement. final int n=j0+1-i0; // number of items to be sorted ^ But The following is OK. class Dummy3{ public void dumb(int i0, int j0){ int n=j0+1-i0; } } (*Scream*) Thanks.... I feel better now. -- http://www.csci.csusb.edu/dick/signature.html Disclaimer: CSUSB may or may not agree with this message. Copyright(1996):Copy freely but say where it came from! I have nothing to sell, and I'm giving it away. From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!math.ohio-state.edu!uwm.edu!lll-winken.llnl.gov!venus.sun.com!news2me.EBay.Sun.COM!engnews2.Eng.Sun.COM!positive!linden Sat Apr 6 08:05:22 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!math.ohio-state.edu!uwm.edu!lll-winken.llnl.gov!venus.sun.com!news2me.EBay.Sun.COM!engnews2.Eng.Sun.COM!positive!linden From: linden@positive.eng.sun.com (Peter van der Linden) Newsgroups: comp.lang.java Subject: Re: Why array.length not length()? Date: 1 Apr 1996 17:36:04 GMT Organization: Sun Microsystems Computer Corporation Message-ID: <4jp464$pfu@engnews2.Eng.Sun.COM> NNTP-Posting-Host: positive.eng.sun.com Cc: Lim Thye Chean wrote: > There is a small problem that puzzle me: why array use array.length to > determine length, but string uses string.length()? From page 143 of "Just Java" published by SunSoft Press, written by me, "Think of it this way, for an array, length is just a final data field set when the array object is created. There is no need to have the overhead of a method call." ... "since Strings are fixed in size once created, why isn't length just a final data field [for String]? The thinking seems to be that it is better for String to be consistent with StringBuffer (which has to do it via a method)... " Peter van der Linden -- Peter van der Linden linden@sun.com "Dereference misaligned, then cuss. Cause an error on the bus" Java powered----> http://www.best.com/~pvdl From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!agate!howland.reston.ans.net!gatech!newsfeed.internetmci.com!in2.uu.net!psinntp!psinntp!psinntp!psinntp!telesph.com!usenet Tue Apr 9 08:33:49 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!agate!howland.reston.ans.net!gatech!newsfeed.internetmci.com!in2.uu.net!psinntp!psinntp!psinntp!psinntp!telesph.com!usenet From: Christopher Helck Newsgroups: comp.lang.java Subject: Rotations & Layouts Date: Mon, 01 Apr 1996 09:06:50 -0500 Organization: Telesphere Corp. Message-ID: <315FE2FA.4563@telesph.com> NNTP-Posting-Host: vulcan.telesph.com Greetings. I sent a similar message to the Java mailing list last week but it seems to have been lost. I apologize if this is a repeat. Here are some tips, techniques, and opinions. Rotations: Lately I've been seeing lots of questions about rotating text and images. I have never tried rotating text but I will assume that if you can rotate an image then you can rotate text. You might draw the text on a graphic object and then use the CropFIlter to create an Image. Let me know if it works :-). To rotate an image you will need an ImageFilter. Fortunately Sun provides one in its online tutorial at http://www.javasoft.com/tutorial/ui/drawing/example/RotateFilter.java It works. It has examples. What more could you want? Well, I actually needed something slightly different, I needed to ratate an image by 90 degrees with no distortion so I wrote a filter called Rotate90Filter. You can find it at: http://www.walrus.com/~check/src/Tiler/Rotate90Filter.java Rotating images can be slow. The best approach is to eliminate unnecessary or redundant rotations (optimizing the filter won't buy you that much). One approach is to use double buffering. Note: The Rotation filters assume that setDimension() is the first method called. This may not be strictly kosher -- the ImageProducer and ImageConsumer can call their methods in any order (I think). Can anyone comment on this? Layouts: I also see lots of questions about Layout Managers and about GridBagLayout in particular. I think that writing a geneeral purpose, very flexible, and powerful layout manager is very difficult. GridBagLayout is a nice try -- it is certainly better than anything I've written. But, I could never get it to do what I want. So I wrote my own specialized layout manager -- I needed to have square components that would remain square after resizing. My point is this: if you are struggling with Layout managers try rolling your own. The benifits are: complete control, and self-education. I found that the GridLayout and CardLayout managers were good ones to study. Tip: A lot of people want to change their layouts when some event occurs -- if a button is pressed display 3 text panels -- if another button is pressed display a graphic panel. Use the CardLayout and save yourself a lot of work. Tip: If you create a GridLayout with three panels and don't add 3 components it may get confused. At one time I had a bug where panels were being drawn all over the place, I went back and made sure that I was adding the right number of components to each layout -- this cleared things up. If you write your own layout manager you might want to add a sanity check if appropos. Having fun, Christopher Helck Telesphere Inc. chris@telesph.com 1 State Street Plaza (212) 487-2784 New York, NY 10004 From csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!newsfeed.internetmci.com!in2.uu.net!alterdial.uu.net!not-for-mail Tue Apr 9 08:40:40 1996 Path: csus.edu!news.ucdavis.edu!library.ucla.edu!info.ucla.edu!newsfeed.internetmci.com!in2.uu.net!alterdial.uu.net!not-for-mail From: Walter@adco.com (Walter Szewelanczyk) Newsgroups: comp.lang.java Subject: Re: Integer I/O Date: 3 Apr 1996 16:56:36 GMT Organization: NET VENTURE, Inc. Message-ID: <4juak4$p1k@alterdial.UU.NET> NNTP-Posting-Host: lazlo.adco.com X-Newsreader: WinVN 0.99.7 In article <316050F4.6DC1@eng.auburn.edu>, carlisle@eng.auburn.edu says... > >I am running Sun Solaris 2.5. Am having problems with Java integer >IO in an application. > >the following program: > >import java.io.* >public class Input { > public static void main (String argv[]) { > DataInputStream inStream = new DataInputStream(System.in); > DataOutputStream outStream = new DataOutputSteam(system.out); > int n; > System.out.print("Input n: "); > // following line is needed to see prompt ...why? > System.out.flush(); > try { n = inStream.readInt(); > outStream.writeInt(n); > outStream.flush(); } catch(IOException e) { > System.out.print("Error"); } > } >} > >This works fine if the integer is long enough to overcome the >buffering problem...i.e. this program works for 5 digit integers >but not for single digit ones.... > >Now...if I modify the above program, deleting the outStream >and try { System.out.println(" n is: " + n); } I will get >garbage out. However if I assign 3 to n rather than read >it with a DataInputStream method the above prints the assigned >value. > >WHAT's the deal? > >BTW....the following seems to work fine.... >String line = instream.readLine(); >m = Integer.valueOf(line).intValue(); >for those who REALLY need to I/O an integer. > >Please reply by e-mail to carlisle@eng.auburn.edu. >Thanks. > Hi Homer, The deal is that readInt() is reading a 4 byte binary representation of an integer. Not a textual represntation of an integer. System.in is reading in ascii text characters, not the binary equivalent. This is why your String line = instream.readLine(); m = Integer.valueOf(line).intValue(); this works. Here you are reading a string that represents an integer and converting it to an actual integer. Hope this helps, Walt From lewikk@rdxsunhost.aud.alcatel.com Wed Mar 13 08:04 PST 1996 Date: Wed, 13 Mar 96 09:52:26 CST Message-Id: <9603131552.AA28735@grasshopper.aud.alcatel.com> From: lewikk@rockdal.aud.alcatel.com (Kevin K. Lewis) In-Reply-To: <199603131501.HAA31062@csci.csusb.edu> (dick@csci.csusb.edu) Subject: Re: newbie: templates in Java ? Reply-To: lewikk@grasshopper.aud.alcatel.com > From: dick@csci.csusb.edu (Dr. Richard Botting) > Date: Wed, 13 Mar 1996 07:01:29 -0800 > > In theory at least an OO language should sort out the > multiple implementations of a compare for different types > for us.... however I also need different kinds of comparison > with in a type: > sort by name > sort by SSN > sort by Date_of_birth Actually, I can't think of a way of doing this in any language without creating three different classes/interfaces: interface Comparable { public int compare(Comparable o); } // My Java gets a bit sketchy at this point ... abstract class ComparableStudent implements Comparable { String name; String ssn; Integer date_of_birth; public int compare(Comparable o); // Is this the right way? ... } // These names seem icky. Maybe you can come up with better ones. class ComparableStudentByName extends ComparableStudent { public int compare(Comparable o) { // Should this cast to `ComparableStudent', instead? return name.compareTo(((ComparableStudentByName)o).name); } } class ComparableStudentBySSN extends ComparableStudent { public int compare(Comparable o) { return ssn.compareTo(((ComparableStudentBySSN)o).ssn); } } etc. Then you instantiate Students based on how you're going to sort them in your `SortableArray' (hope I'm not missing another obvious "oh, by the way"). > From: dick@csci.csusb.edu (Dr. Richard Botting) > Date: Wed, 13 Mar 1996 07:02:14 -0800 > > This is giving me a headache! > Dang... why can't they catch up with 1983! Unlikely. I think that pop-CS will always be way behind what's easily doable and useful; just look at MS-Windows which is at least 20 years behind in OS technology (except for the pretty face, which is only 5 or so years behind). This may be good, though; otherwise I might have to get a CS degree (I'm a lowly EE graduate ;-). -- Kevin K. Lewis | My opinions may be unreasonable lewikk@aud.alcatel.com | but such is the voice of inspiration From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!qns3.qns.com!imci4!newsfeed.internetmci.com!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!lll-winken.llnl.gov!sol.ctr.columbia.edu!news.mindlink.net!van-bc!unixg.ubc.ca!news.bc.net!news.bcit.bc.ca!news Sat Apr 13 07:12:31 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!qns3.qns.com!imci4!newsfeed.internetmci.com!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!lll-winken.llnl.gov!sol.ctr.columbia.edu!news.mindlink.net!van-bc!unixg.ubc.ca!news.bc.net!news.bcit.bc.ca!news From: D'Arcy Smith Newsgroups: comp.lang.java Subject: Re: "Static methods can't be abstract" Date: Thu, 04 Apr 1996 14:07:08 -0800 Organization: ARCS Lab, BCIT Message-ID: <3164480C.1517@arcs.bcit.bc.ca> <4jsrom$33c@shellx.best.com> <31620D1B.37AC@imaginary.com> <4jt5r6$b6u@shellx.best.com> <4judp4$oik@oblivion.utdallas.edu> Reply-To: darcy@arcs.bcit.bc.ca NNTP-Posting-Host: bird.arcs.bcit.bc.ca Glenn Vanderburg wrote: > > Jef Poskanzer writes: > > > > Ah, this is the problem. I was assuming that static methods could be > > inherited. Now I'll have to think about why that can't be. Offhand > > I don't see a good reason. > > I haven't been able to think of a reason for this either. Unlike George, > I don't think it's nonsensical to inherit a static method. > > Jef, you and I apparently encountered this the same way: trying to build > an Application class with a "main" method which could be inherited and > shared by multiple applications. I'd really like to know why this is not > allowed to work. I think a lot of this depends on terminiology. 1) You inherit static methods to the extent that you have access to them 2) You cannot change the way a static mothod works (override) in a sub-class and have it work at all times. given: class Base { public static void f() { System.out.println("Base"); } } class Derived1 extends Base { public static void f() { System.out.println("Derived1"); } } class Derived2 extends Base { } class Test { public static void main(String argv[]) { Base b = new Base(); Base d1a = new Derived1(); Base d2a = new Derived2(); Derived d1b = new Derived1(); Derived d2b = new Derived2(); b.f(); // output: Base d1a.f(); // output: Base d2a.f(); // output: Base d1b.f(); // output: Derived1 d2b.f(); // output: Base } } So yes, static functions are inherited, but no they are not treated the same as non-static (virtual) methods. 3. Yes you can use an "inherited main" (I've done it). abstract class App { public static void main(String argv[]) { processArgs(argv); go(); } protected abstract boolean processArgs(String argv[]); protected abstract void go(); } class MyApp extends App { protected abstract boolean processArgs(String argv[]) { return true; } protected abstract void go() { /* ... */ } } ..darcy -- D'Arcy Smith, Systems Analyst Applied Research in Computer Systems (ARCS) Laboratory British Columbia Institute of Technology (BCIT), Burnaby, BC, Canada E-Mail: darcy@arcs.bcit.bc.ca URL http://www.arcs.bcit.bc.ca Tel: (604) 432-8281 Fax: (604) 436-1297 From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!imci3!imci2!news.internetMCI.com!newsfeed.internetmci.com!sgigate.sgi.com!news1.best.com!nntp1.best.com!shellx.best.com!not-for-mail Sat Apr 13 07:13:18 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!imci3!imci2!news.internetMCI.com!newsfeed.internetmci.com!sgigate.sgi.com!news1.best.com!nntp1.best.com!shellx.best.com!not-for-mail From: Jef Poskanzer Newsgroups: comp.lang.java Subject: Re: "Static methods can't be abstract" Date: 5 Apr 1996 10:08:11 -0800 Organization: Paratheo-Anametamystikhood Of Eris Esoteric Message-ID: <4k3nib$ktj@shellx.best.com> Reply-To: Jef Poskanzer NNTP-Posting-Host: shellx.best.com X-Face: uPIE),q]+zmF49L%(pdE;nX/8$/J22&&&C@_)8BouYx42Y--?*,\]*MIeTY#mCM(x>FyD@+0D-Jm]S_8lxop(Q-$L#~b8!ha;eF[b+GOLyu<]4$">NeVymJ@F#M?1O`ue4,h4`2S^KGjmP%no(d,:3. Yes you can use an "inherited main" (I've done it). > abstract class App { > public static void main(String argv[]) { > processArgs(argv); > go(); > } > > protected abstract boolean processArgs(String argv[]); > protected abstract void go(); > } > > class MyApp extends App { > protected abstract boolean processArgs(String argv[]) { return true; } > protected abstract void go() { /* ... */ } > } The code as posted does not compile. The first problem is the abstracts in MyApp. Take those out and you run into the second problem: the static main in App can't call the non-static processArgs and go methods. That can be fixed in two ways, either have main() create an instance, or make processArgs and go be static. If you try having main() make an instance, you find that javac won't let you make an instance of an abstract class. If you make the routines static, you run into the error message that started this thread: static methods can't be abstract. If you remove all but the main(), just to see if the inherited main gets called, you get a load-time error: main is not defined. In summary: if you want to convince me that an inherited main can actually be made to work, you're going to have to post code that really works. --- Jef Jef Poskanzer jef@acme.com http://www.acme.com/jef/ "No man is so poor that he need sit on a pumpkin." -- Henry Thoreau From csus.edu!newshub.csu.net!imci3!imci4!newsfeed.internetmci.com!news.kei.com!news.texas.net!news1.best.com!nntp1.best.com!shellx.best.com!not-for-mail Sat Apr 13 07:15:04 1996 Path: csus.edu!newshub.csu.net!imci3!imci4!newsfeed.internetmci.com!news.kei.com!news.texas.net!news1.best.com!nntp1.best.com!shellx.best.com!not-for-mail From: Jef Poskanzer Newsgroups: comp.lang.java Subject: Re: "Static methods can't be abstract" Date: 5 Apr 1996 19:45:49 -0800 Organization: Paratheo-Anametamystikhood Of Eris Esoteric Message-ID: <4k4pdd$etn@shellx.best.com> Reply-To: Jef Poskanzer NNTP-Posting-Host: shellx.best.com X-Face: uPIE),q]+zmF49L%(pdE;nX/8$/J22&&&C@_)8BouYx42Y--?*,\]*MIeTY#mCM(x>FyD@+0D-Jm]S_8lxop(Q-$L#~b8!ha;eF[b+GOLyu<]4$">NeVymJ@F#M?1O`ue4,h4`2S^KGjmP%no(d,:: }Jef Poskanzer wrote: }> In summary: if you want to convince me that an inherited main can }> actually be made to work, you're going to have to post code that }> really works. } }Though I am not the one to whom you are responding, I did post }*something* that will work like you want... } }public class Base { } public static void main(String argv[]) { } do_main_things(); } } }} } }public class App extends Base { } public static void main(String argv[]) { } Base.main(argv); } } }} } }Is this inheritance? No. But it does exactly what you want. No, it's useless. You missed the point of the part of D'Arcy's article that I didn't quote: static methods *are* inherited. Below is his example code again, slightly modified so it compiles. The Derived2 class does not have an f method, and yet calling Derived2.f(), whether via an instance or directly, calls Base.f(). This really does work. Static methods really are inherited. And yet for some reason, a static main() is *not* inherited. I suspect there's a bug specific to main(), not a general misfeature of static methods. If so there's an excellent chance it can be fixed. Note that this shows there is no good reason for the prohibition on abstract static methods. --- Jef Jef Poskanzer jef@acme.com http://www.acme.com/jef/ "Say yur prayers, yuh flea-pickin' varmint!" -- Yosemite Sam - - - - - - Test.java - - - - - - class Base { public static void f() { System.out.println("Base"); } } class Derived1 extends Base { public static void f() { System.out.println("Derived1"); } } class Derived2 extends Base { } class Test { public static void main( String argv[] ) { Base b = new Base(); Base d1a = new Derived1(); Base d2a = new Derived2(); Derived1 d1b = new Derived1(); Derived2 d2b = new Derived2(); b.f(); // output: Base d1a.f(); // output: Base d2a.f(); // output: Base d1b.f(); // output: Derived1 d2b.f(); // output: Base Derived1.f(); // output: Derived1 Derived2.f(); // output: Base } } From csus.edu!druid.borland.com!news.sprintlink.net!new-news.sprintlink.net!tank.news.pipex.net!pipex!dish.news.pipex.net!pipex!news.airtime.co.uk!usenet Sun Apr 14 07:29:54 1996 Path: csus.edu!druid.borland.com!news.sprintlink.net!new-news.sprintlink.net!tank.news.pipex.net!pipex!dish.news.pipex.net!pipex!news.airtime.co.uk!usenet From: wysiwyg@glympton.airtime.co.uk (Adam L Rice) Newsgroups: comp.lang.java Subject: Re: HELP!!! Applet works AND doesn't work! Date: 4 Apr 1996 11:59:47 +0100 Organization: The Rice family. Message-ID: <4k0a33$1jj@glympton.airtime.co.uk> NNTP-Posting-Host: glympton.airtime.co.uk In article , Alexander Anderson wrote: > The Java Console says: > > ># Applet exception: error: BorderWindow >java.lang.IllegalAccessError: BorderWindow > at Robot.(Robot.java:41) > at netscape.applet.EmbeddedAppletFrame.run(EmbeddedAppletFrame.java:230) > at java.lang.Thread.run(Thread.java:289) Did you compile the program with javac -O? It sometimes creates direct links to private variables when it's inlining a method from another class. This caused me to get an error like this once. Try recompiling Robot.java without the -O option. ,==========================================================================. | \ /\/( |\ /\//' | Adam L Rice -|- wysiwyg@glympton.airtime.co.uk | | \/\/ / )| \/\/ / \_| | Resume: http://www.csv.warwick.ac.uk/~mauhb/cv | `==========================================================================' From csus.edu!sacsa3.mp.usbr.gov!donews.do.usbr.gov!usbr.gov!csn!news-1.csn.net!decwrl!amd!netcomsv!uu4news.netcom.com!delilah.wilshire.com!tomkwong Sun Apr 14 07:40:29 1996 Path: csus.edu!sacsa3.mp.usbr.gov!donews.do.usbr.gov!usbr.gov!csn!news-1.csn.net!decwrl!amd!netcomsv!uu4news.netcom.com!delilah.wilshire.com!tomkwong From: tomkwong@West.Sun.COM () Newsgroups: comp.lang.java Subject: Re: Testing Applets with Netscape? Date: 11 Apr 1996 20:09:18 GMT Organization: Wilshire Associates, Inc. Message-ID: <4kjote$k55@delilah.wilshire.com> NNTP-Posting-Host: discover.wilshire.com In article <316596EC.1EBB@comm.hq.af.mil> "Stephen C. Johnson" writes: > >If you get tired of waiting for NS to load up, close, and load >up when you recompile a class, I would suggest testing your >applets through the appletviewer included with the JDK. Once >the applet is good to go, spruce up the HTML and view it with >NS. It saves me quite a bit of time during development... I almost always make an applet run as an application during development. I use code like the following: public class CardDemo extends java.applet.Applet { ... } public static void main(String args[]) { Frame f = new Frame("Card Demo"); CardDemo demo = new CardDemo(); demo.init(); f.add("Center", demo); f.pack(); f.resize(f.preferredSize()); f.show(); } ACME (http://www.acme.com/java/software) even has an application framework. Tom From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!gatech!newsfeed.internetmci.com!in1.uu.net!world!mv!usenet Tue Apr 16 06:57:30 1996 Newsgroups: comp.lang.java Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!gatech!newsfeed.internetmci.com!in1.uu.net!world!mv!usenet From: joe@millar.mv.com (Joseph Millar) Subject: Re: Packages... Aiigh! Please help! Message-ID: Organization: MV Communications, Inc. Date: Sun, 7 Apr 1996 16:08:31 GMT X-Newsreader: Forte Free Agent 1.0.82 X-Nntp-Posting-Host: millar.mv.com "Zacharias J. Beckman" wrote: >Ok, I'm just not understanding this. I can't seem to get packages, as a >general concept, to work for me. >I've created a directory ~/Developer/Dreams. >I've set CLASSPATH to ~/Developer. >I've placed "package Dreams.PictureCanvas" at the top of my code. >I've a file called PictureCanvasApplet.java in the directory... > ~/Developer/Dreams/PictureCanvas >All compiles fine, but when I try to use appletviewer this is what I get >back: >231% appletviewer PictureCanvasApplet.html >thread applet-PictureCanvasApplet.class find class PictureCanvasApplet >Opening stream to: >file:/C:/Users/zac/Developer/Dreams/PictureCanvas/PictureCanv >asApplet.class to get PictureCanvasApplet >File format exception when loading: PictureCanvasApplet >load: class PictureCanvasApplet not found >java.lang.ClassNotFoundException: PictureCanvasApplet > at >sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:125) > at >sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:101) > at sun.applet.AppletPanel.run(AppletPanel.java:200) > at java.lang.Thread.run(Thread.java:289) >232% > [snip!] >Please help! This is driving me crazy! Thanks in advance... I can't be certain without your .html file, but after a simple test with the provided code it looks like your .html contains something like: and that you might be running this from the Dreams/PictureCanvas directory. When appletviewer tries to load PictureCanvasApplet it loads PictureCanvasApplet.class from the current directory, but when reading the file it can only find Dreams.PictureCanvas.PictureCanvaseApplet, which is different than PictureCanvasApplet. To make it work, I changed the .html file's CODE= tag to read: Hope this helps. Joe Millar joe@millar.mv.com From csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!samba.rahul.net!rahul.net!a2i!bug.rahul.net!rahul.net!a2i!genmagic!sgigate.sgi.com!swrinde!howland.reston.ans.net!vixen.cso.uiuc.edu!glhpx11!j-waldby Thu Apr 18 05:47:08 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!samba.rahul.net!rahul.net!a2i!bug.rahul.net!rahul.net!a2i!genmagic!sgigate.sgi.com!swrinde!howland.reston.ans.net!vixen.cso.uiuc.edu!glhpx11!j-waldby From: j-waldby@glhpx11.cen.uiuc.edu (James Irl Waldby) Newsgroups: comp.lang.java Subject: Re: how to convert #xxxxxx to xxx,xxx,xxx Date: 8 Apr 1996 05:54:56 GMT Organization: University of Illinois at Urbana Message-ID: <4ka9ng$n1d@vixen.cso.uiuc.edu> NNTP-Posting-Host: glhpx11.cen.uiuc.edu sonik@hooked.net (Gabe) writes: >Does anyone out there know how to convert a color supplied as #xxxxxx >like #abc123 to a xxx,xxx,xxx RGB format? LIke say a tag has PARAM NAME="fg" VALUE="#cfcfcf"> ... i want to get that color and put >it to 200,200,200 (or whatever it is). An example on page 161 of Hooked on Java might do what you want if you leave off the # sign ... its code says in part: public Color colorFromString(String s, Color defaultColor) { Integer i; try { i = Integer.valueOf(s, 16); return new Color(i.intValue()); } catch (NumberFormatException e) { if (s.equalsIgnoreCase("red")) { return Color.red; } else if (s.equalsIgnoreCase("green")) { and so forth. Note base 16 in fourth line. Some shorter code that gets Color from name (so I can say (eg) ) appears in applets at http://biobio.cs.uiuc.edu/~j-waldby/japplets.html (The Color Table applet only paints once for some reason I've yet to figure out.) From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!cs.utexas.edu!swrinde!sgigate.sgi.com!news.corp.sgi.com!inn Thu Apr 18 05:47:43 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!cs.utexas.edu!swrinde!sgigate.sgi.com!news.corp.sgi.com!inn From: Slumbering Mantis Newsgroups: comp.lang.java Subject: Re: how to convert #xxxxxx to xxx,xxx,xxx Date: Sun, 07 Apr 1996 23:14:30 -0700 Organization: the clutch Message-ID: <3168AEC6.41C6@eating.a.corpse> NNTP-Posting-Host: isdn-underworld.corp.sgi.com Gabe wrote: > > Heya, > > Does anyone out there know how to convert a color supplied as #xxxxxx > like #abc123 to a xxx,xxx,xxx RGB format? LIke say a tag has PARAM NAME="fg" VALUE="#cfcfcf"> ... i want to get that color and put > it to 200,200,200 (or whatever it is). > Given: (no pound sign) What I do is: ....begin code fragment int red, green, blue; String param = getParameter("COLOR"); if (param != null) { red = Integer.parseInt(param.substring(0,2),16); green = Integer.parseInt(param.substring(2,4),16); blue = Integer.parseInt(param.substring(4,6),16); } ....end code fragment Good Luck, Mike mjimenez@studio.sgi.com > Thanks, > --- > Gabe > sonik@hooked.net > http://www.terminalp.com From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!paladin.american.edu!zombie.ncsc.mil!news.mathworks.com!newsfeed.internetmci.com!news.msfc.nasa.gov!sgigate.sgi.com!news1.best.com!nntp1.best.com!shellx.best.com!not-for-mail Thu Apr 18 06:15:19 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!paladin.american.edu!zombie.ncsc.mil!news.mathworks.com!newsfeed.internetmci.com!news.msfc.nasa.gov!sgigate.sgi.com!news1.best.com!nntp1.best.com!shellx.best.com!not-for-mail From: kbs@shellx.best.com (KB Sriram) Newsgroups: comp.lang.java Subject: LL(1) parser generator available Date: 8 Apr 1996 16:02:05 -0700 Organization: Best Internet Communications Message-ID: <4kc5td$t2u@shellx.best.com> NNTP-Posting-Host: shellx.best.com An alpha version of a parser generator "jell" for LL(1) grammars is available at http://www.blackdown.org/~kbs http://www.best.com/~kbs (No wars about the relative merits of LL or LR parsers please, just use whatever gets the job done quicker :-) Jell generates recursive descent parsers. It accepts specifications in an extended BNF like format, provides some automatic error report and recovery, and allows (semantic) predicates to aid in parsing non LL(1) grammars. You can use any tokenizer, but jell itself uses a scanner generator "jax" (yeah, groan) which you can obtain from the same site. Jax is not a lex lookalike, for that look at Elliot Berk's JavaLex. Jax's limitations are that it handles only 7bit ascii, and doesn't do multiple start states or context sensitive regular expressions or space optimizations. Jax and jell are in the *alpha* stage, and all I know for sure is that both their tokenizers and parsers (written with each other) regenerate identically. All other bets are off, but I'll fix bugs as quick as I can if you mail them to me ;-) Pointers to existing Java parser/scanner generators (is this complete?) * JavaCUP (Scott Hudson's LALR parser generator) http://www.cc.gatech.edu/gvu/people/Faculty/hudson/java_cup/home.html * jb (tcl script to postprocess bison output to java) ftp://ftp.cs.colorado.edu/pub/cs/distribs/arcadia/jb.txt * JavaLex (Elliot Berk's lex lookalike) http://www.cs.princeton.edu/~ejberk/JavaLex/JavaLex.html * Regexp package (Jonathan Payne's *runtime* regular expression matcher) http://www.starwave.com/people/jpayne/java/regexp/ -KB- From csus.edu!dick Thu Apr 18 06:24:56 1996 Path: csus.edu!dick From: dick@silicon.csci.csusb.edu (Dr. Richard Botting) Newsgroups: comp.lang.java Subject: Functions as objects! Date: 9 Apr 1996 15:29:58 GMT Organization: CS Dept., Calif. State Univ., San Bernardino Message-ID: <4kdvpm$60u@news.csus.edu> NNTP-Posting-Host: dick%@blaze.csci.csusb.edu X-Newsreader: TIN [version 1.2 PL2] There was a discussion arlier about the possibillity and goodness for treating functions as objects in Java. It is quite easy, and indeed interesting to declare a Java intervase that abstracts the meaning of a function: Something that can be applied to an Object, and returns and object: interface Function{ public Object of(Object arg); } You can then declare a class implementing Function, and then hand in objects of that class to other methods of objects... Here is the paradigmatic example -- integerating a function (Unchecked code!) class Quadrant implements Function{ public Object of(Object arg){ return sqrt(1-arg.doubleValue()arg.doubleValue()); } } Function f = new Quadrant; double mypi=4*Integrators.simpson(f, 0,1); where Integrators.simpson(Function f, double lo, double hi) returns a double aproximately equal to the result of integrating f(x) with respect to x from lo to hi. Please see the documentation in http://www.csci.csusb.edu/cs320/java/Function.html For real examples and even a Composition functor-Object, see ftp://www.csci.csusb.edu/cs320/java/fun3.java This technique is based on an article I remember from in another Usenet Newsgroup that discusses a Certain hybrid language. I regret that I've lost the detailed citation. Two quick examples of why you might like to have such an interface in your library: //disclaimer.... unchecked code below.... bugs ahead AdditiveObject Sigma(Function term, int n, int m){ AdditiveObject sum; for(int i=n;i0.5){ (new ParametricArc(from, mid)).display(); (new ParametricArc(mid, to)).display(); }else display_line_whatever(fromx,fromy,tox,toy); } //+lots of fun things to do with arcs of curves } -- dick botting http://www.csci.csusb.edu/dick/signature.html Disclaimer: CSUSB may or may not agree with this message. Copyright(1996): Copy freely but say where it came from. "Why climb it? Because it is there." From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!news.cps.udayton.edu!news.engr.udayton.edu!blackbird.afit.af.mil!zombie.ncsc.mil!news.mathworks.com!tank.news.pipex.net!pipex!warwick!lyra.csx.cam.ac.uk!sunsite.doc.ic.ac.uk!info-server.surrey.ac.uk!usenet Fri Apr 19 07:44:57 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!news.cps.udayton.edu!news.engr.udayton.edu!blackbird.afit.af.mil!zombie.ncsc.mil!news.mathworks.com!tank.news.pipex.net!pipex!warwick!lyra.csx.cam.ac.uk!sunsite.doc.ic.ac.uk!info-server.surrey.ac.uk!usenet From: Snorre Narum Newsgroups: comp.lang.java Subject: mathclass, please comment Date: Wed, 10 Apr 1996 15:44:20 +0100 Organization: University of Surrey, Guildford, England Message-ID: <316BC944.1207@surrey.ac.uk> NNTP-Posting-Host: kira.ee.surrey.ac.uk I am currently completing the work of my undergrad project at the university and I have some comments to java etc. My class takes a string formatted using the (as close as possible) TeX format of math formulas. It also takes the desired fontsize as input, and what it generates is a graphical representation of the formula. i am aware of several other such classes, but they are all limited to a certain size as they use gif images frequently for symbols not supported. My goal was to make a more flexible classlibrary than those. When I started the project I was under the impression that java could handle locally stored fonts. According to Arthur van Hoff this should be possible, but after weeks of experimenting I gave this up, and limited the project to using only the 5 predefined fonts, ergo only latin characters, and then made it flexible to expand the class library whenever sun got around to include more fonts. But this was not the end of my griefs. When finishing the classes satisfied with the output, I copied the program from my pc and onto a sun sparc station and to my great surprise I found out that the fonts i use are not scaleable on the sparc station (Symbol and TimesRoman), which resulted in an awfull blocky output. Also I found out that some examples that worked excelent under win95 took ages on the sparc and some even just hang. Further experiments showed me that even under similar configurations the output varied. Some pc's antialiased the fonts and some didnt. Some machines (I predict the slow ones) used massive amount of memory to run the program (as much as 22 mb) while on my machine it used insignificantly amounts. The speed also varied alot, and my final overall impression was that the java implementation for win32 is by far the most stable and predictable, and also faster. On my 75mhz pentium it takes about .5 sec to execute the applet while on a sparc 5 it takes at least 15 sec (and it even looks shite) The worst example is when i ran the program from a sparc 1000 via a terminal where the applet caused an exception when trying to load the fonts, saying something like fileNotFoundException. To me these things are just as fine. Gives me lots to write about in the report. But this is not the effects of a distributed programming language. When java limits you as much as it does, you should be able to predict the output. If you are interested to have a look at the program use netscape or appletviewer on: http://www.ee.surrey.ac.uk/Societies/norsoc/homepages/ee41sn/project/example1.html http://www.ee.surrey.ac.uk/Societies/norsoc/homepages/ee41sn/project/example2.html http://www.ee.surrey.ac.uk/Societies/norsoc/homepages/ee41sn/project/example3.html http://www.ee.surrey.ac.uk/Societies/norsoc/homepages/ee41sn/project/example4.html I want to make a javascript page so you can edit the formula yourself, but I will have to postpone that until after the exams. Any kind of response to this would be highly appreciated. If you feel in the very helpfull corner, please grab the output on your screen ( while displaying the applet :) describe your systmem, and email it to me. Sourcecode, classes and documentation can be sent on request. oh, and another thing, about symantec cafe. i like the tool, but think it is inconveniente to have to set up a network in order to make the debugger to work. never got it to work on my standalone pc, aparently because you cant set up a network under win95 before you have a network card installed. and why to have that on a standalone machine??? and another thing, when part of you project is a package, symantec refuses to compile those files. rather annoying. well thats all for me. -- ----------------------------------------------------------------- Snorre Narum ee41sn@surrey.ac.uk http://www.ee.surrey.ac.uk/Societies/norsoc/homepages/ee41sn/ *--- The opinions expressed in this message are not my own personal views, and reflect the official views of Bill Gates. ----------------------------------------------------------------- From csus.edu!tns.sdsu.edu!newshub.sdsu.edu!newshub.csu.net!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!EU.net!Germany.EU.net!Dortmund.Germany.EU.net!Informatik.Uni-Dortmund.DE!burgund!frey Sun Apr 21 09:03:47 1996 Path: csus.edu!tns.sdsu.edu!newshub.sdsu.edu!newshub.csu.net!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!EU.net!Germany.EU.net!Dortmund.Germany.EU.net!Informatik.Uni-Dortmund.DE!burgund!frey From: frey@burgund.informatik.uni-dortmund.de (Christian Frey) Newsgroups: comp.lang.java Subject: CLASSPATH-Conflict: Netscape & JDK-1.0.1 under Solaris 2.4 Date: 12 Apr 1996 16:17:47 GMT Organization: CS Department, Dortmund University, Germany Message-ID: <4klvnb$cko@fbi-news.Informatik.Uni-Dortmund.DE> NNTP-Posting-Host: burgund.informatik.uni-dortmund.de The problem: The classes-files of the JDK (classes.zip) and of Netscape 2.0/2.01 (moz2_0.zip/moz2_01.zip) are having conflicts under Sparc-Solaris 2.4 if there exists an CLASSPATH-variable referencing to one (or both) of these files. If a) the path to classes.zip stands in front of moz2_0.zip in CLASSPATH (or moz2_0.zip is not in the CLASSPATH) I am not able to view applets within Netscape, though moz2_0.zip is in ~/.netscape (one of the default-directories); b) moz2_0.zip comes first I am able to view applets :-), but now I have problems with starting applications which use the AWT. I tried the FileViewer-Application from 'Java in a Nutshell' and a window came up that was sometimes empty and somtimes contained the components it should, but wasn't reacting at all (e.g. the scrollbars were not working); after removing the moz2_0.zip-entry out of my CLASSPATH the application behaved the way it should; c) there isn't any CLASSPATH and moz2_0.zip is located in one of the standard-directories, then everything is fine except that the command-line gets it bit long when compiling/starting programs. I hope that my description was not to confusing and that I didn't overlook a trivial problem-solution. Thanx for any advice! Christian Frey (frey@ls3.informatik.uni-dortmund.de) From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cs.utexas.edu!uwm.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!newsxfer.itd.umich.edu!qiclab.scn.rain.com!pub.multnomah.lib.or.us!netnews3.nwnet.net!nwnet!netnews10.nwnet.net!netnews2.nwnet.net!starwave.com!news_admin@starwave.com Mon Apr 22 06:55:56 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cs.utexas.edu!uwm.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!newsxfer.itd.umich.edu!qiclab.scn.rain.com!pub.multnomah.lib.or.us!netnews3.nwnet.net!nwnet!netnews10.nwnet.net!netnews2.nwnet.net!starwave.com!news_admin@starwave.com From: David Geller Newsgroups: comp.lang.java Subject: Re: disappointed with Java Date: Tue, 09 Apr 1996 00:06:06 -0700 Organization: Starwave Corporation Message-ID: <316A0C5E.2640@starwave.com> Reply-To: geller@starwave.com NNTP-Posting-Host: shiva-di7.starwave.com Falchion wrote: > Does anybody else think that Java is a bit overhyped? Lots of people. But for some, they haven't learned the significance of Java. For one - it's a full language -- not just something you use with a browser. We're doing lots of development today where Java has taken the place of C++. And for applet deployment - Java is still a good choice. If you need to draw bits on the screen - a scripting language generally doesn't cut it and plug-ins are platform dependent. Java has its problems (because of it relativeness newness) -- but it looks like there's enormous support and rapid advances are likely. If you compare it as a language and toolset it's significantly richer than, say, Microsoft C++ and MFC was back in the 1.0 days. Once you've started programming with the Java classes - it's hard to go back to C++. > I've learnt the basics of Java and had a look at a few > applets, and I'm not sure what all the fuss is about. > Most of the animations I've seen are really bad flickering animations > or take ages to load. The spinning logo on Gamelan's front page > causes my 486DX66 (8MB RAM) to almost keel over and die. I've also > tried loading Gamelan's front page from a Sun workstation and it is > still quite slow to load. Sounds like you've simply been exposed to poor examples of Java programming. To be fair, though, it's true that Java can overtax the resources of many machines. Expect Microsoft's upcoming Internet Explorer 3.0 to help. At the ActiveX conference last month they demonstrated their browser running with a Just-In-Time compiler. > I personally think animated GIFs are much better because they are easier to > produce and quicker to load. You have far less control over the way the images are drawn. You can't control frame rate, can't trigger events, draw bits on the screen -- etc. Animated gifs are a hack. Clever - but a hack no less. > I've also been more impressed with Shockwave > animations than Java animations. It's a shame that Director/Shockwave is > so expensive though. Shockwave and Director are cool. > I know it's early days yet, but I haven't really seen any useful or > impressive Java applets. They are starting to appear. Our own ESPN SportsZone is running a pretty sophisticated applet named ScorePost(TM). You can try it out at espnet.sportszone.com (select the "Java" page) > > Oh, and one last nitpick - why does almost every article I read promoting > Java talk about a stock market applet? > It's a good application and demonstration of some of Java's built-in classes for communicating over the Internet. Classes like URL make grabbing content from the web a walk in the park. ---------------------------------------------- David Geller geller@starwave.com Starwave Corporation www.starwave.com From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!lll-winken.llnl.gov!osi-east2.es.net!cronkite.nersc.gov!qiclab.scn.rain.com!pub.multnomah.lib.or.us!netnews3.nwnet.net!nwnet!netnews10.nwnet.net!netnews2.nwnet.net!starwave.com!news_admin@starwave.com Fri May 3 17:06:08 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!lll-winken.llnl.gov!osi-east2.es.net!cronkite.nersc.gov!qiclab.scn.rain.com!pub.multnomah.lib.or.us!netnews3.nwnet.net!nwnet!netnews10.nwnet.net!netnews2.nwnet.net!starwave.com!news_admin@starwave.com From: Carl Haynes Newsgroups: comp.lang.java Subject: Re: Does Object retain the type? Date: Tue, 16 Apr 1996 13:49:51 -0700 Organization: Starwave Corporation Message-ID: <317407EF.7DD5@starwave.com> NNTP-Posting-Host: carlh.starwave.com Lim Thye Chean wrote: > > In Vector, I have to cast everything to Object before I store it. Let's say > I store a String and Integer into Vector, when I retrieve them back, is > there a way to know the retrieved object IS a String OR Integer? - so that > I can cast them back to the original type? > > If not, then I will create a new class called Item which extends Object with > a field called type. Then I create a class extends Vector called Table. > Table stores Item, and you can ask Table what is the type of say, 6th item? You don't need to cast classes to Object before storing them in a Vector, it won't hurt anything though. you can compare objects against known types by using instanceof if (obj instanceof String) { } -- carl haynes, applet guy starwave corp. -- http://www.starwave.com/people/haynes 206-957-2709 -- mailto:haynes@starwave.com my latest applet: http://family.starwave.com/funstuff/scrapbook/easter/ From csus.edu!sacsa3.mp.usbr.gov!usbr.gov!csn!news-1.csn.net!gw1.att.com!fnnews.fnal.gov!uwm.edu!news.cse.psu.edu!news.ecn.bgu.edu!vixen.cso.uiuc.edu!newsfeed.internetmci.com!in2.uu.net!en.com!news.dgsys.com!tahiti.netreach.net!news1.digex.net!news.eclipse.net!usenet Fri May 3 17:08:05 1996 Path: csus.edu!sacsa3.mp.usbr.gov!usbr.gov!csn!news-1.csn.net!gw1.att.com!fnnews.fnal.gov!uwm.edu!news.cse.psu.edu!news.ecn.bgu.edu!vixen.cso.uiuc.edu!newsfeed.internetmci.com!in2.uu.net!en.com!news.dgsys.com!tahiti.netreach.net!news1.digex.net!news.eclipse.net!usenet From: Esther Etherington Newsgroups: comp.lang.java,news.groups Subject: Re: comp.lang.java Newsgroups, Reordering of Date: Tue, 23 Apr 1996 10:31:26 -0400 Organization: tSunami Professional Services Message-ID: <317CE9BE.1DA9@tsu.com> NNTP-Posting-Host: 205.197.63.80 CC: ee@tsu.com Xref: csus.edu comp.lang.java:44871 news.groups:180780 > >What do you others out there feel about the "PvdL modified Java proposal"? > > I'll let others comment. If anyone would like to keep comp.lang.java, > just vote down the creation of comp.lang.java.misc, and Peter can > later run a RFD/CFV for comp.lang.java.d . > > -Urban Most Newbies cross-post when they are desperate to get a question answered. Those that don't cross-post usually post to the "most active" group (i.e. - the one with the most messages) this makes it difficult for the experienced professional to wade through the newbie swamp to get/give high-tech help. The problem is even more complicated by the fact that most newbies don't recognize themselves, and consider all their problems to be "high-tech" and some access providers don't subscribe to all newsgroups within a topic. So there will be certain people out there who only have one java newsgroup on their news server. The providers again usually pick the "most active" one. Do I have a solution? Well, no, I just point out problems. But if you're looking for an easy, sane place to communicate with each other you're welcome to use the Web-based conference board at http://www.JavaMan.com/ just make up a secret user name and password, and you're in. (the user bio is optional, and can be modified later) .......................................... Esther Etherington, WebWeaver ee@tSu.com tSunami Professional Services Presence Providers and Site Developers for the World Wide Web http://www.tSu.com/ http://www.WebClub.com/ http://www.ORBAware.com/ http://www.JavaMan.com/ .......................................... From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!qns3.qns.com!imci4!newsfeed.internetmci.com!howland.reston.ans.net!psinntp!psinntp!psinntp!uknet!pub.news.uk.psi.net!usenet Fri May 3 17:10:22 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!qns3.qns.com!imci4!newsfeed.internetmci.com!howland.reston.ans.net!psinntp!psinntp!psinntp!uknet!pub.news.uk.psi.net!usenet From: bill1@io.com (Bill Ray) Newsgroups: comp.lang.java Subject: Re: Need help.. What's wrong with this code?? Date: Mon, 22 Apr 1996 09:55:17 GMT Organization: PSINet UK Public Usenet Site Message-ID: <4lfkvv$pp8@pub.news.uk.psi.net> NNTP-Posting-Host: 193.123.218.50 X-Newsreader: Forte Free Agent 1.0.82 rclark@mozart.inet.co.th (Robert Clark) wrote: >Hello All! >Well, I'm new to Java, and have been learning it by modifying programs in my >Java book. The normal way... >public class PanelDemo must be defined in a file called "PanelDemo.java". >public class PanelDemo extends Applet { >Please help me out.. I know it's probably a stupid mistake..... > public class PanelDemo extends Applet { Your problem is that PanelDemo is identified as public, take out that word and things should be improved. I'm no Java expert but my applets have only one public class, which is named the same as the filename the applet is saved under. Literally remove the word public in the above line. Lots Of Love Bill Ray From csus.edu!csulb.edu!drivel.ics.uci.edu!news.claremont.edu!nntp-server.caltech.edu!fnnews.fnal.gov!uwm.edu!lll-winken.llnl.gov!enews.sgi.com!sgigate.sgi.com!swrinde!newsfeed.internetmci.com!news.sprintlink.net!unify!Unify.com!lee Fri May 3 17:19:33 1996 Newsgroups: comp.lang.java Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.claremont.edu!nntp-server.caltech.edu!fnnews.fnal.gov!uwm.edu!lll-winken.llnl.gov!enews.sgi.com!sgigate.sgi.com!swrinde!newsfeed.internetmci.com!news.sprintlink.net!unify!Unify.com!lee From: lee@Unify.com (Lee Crocker) Subject: Re: Most annoying Java gotchas Message-ID: Nntp-Posting-Host: zanzibar.sac.unify.com Organization: Unify Corporation (Sacramento) Date: Tue, 23 Apr 1996 19:32:02 GMT > > : > String s = foo.GetSomeString(); > > : > if (s == "Fat chance") > > : > sorryCharlie(); > > What is the fix to this gotcha? How are you supposed to do string comparisons? RTFM: the equals() method does string comparisons. So replace that line with "if (s.equals("Fat Chance"))", or even "if ("Fat Chance".equals(s))". From alopez Sun May 12 20:47 PDT 1996 From: alopez (Aaron P. Lopez) Date: Sun, 12 May 1996 20:30:39 -0700 Message-Id: <199605130330.UAA25228@csci.csusb.edu> Subject: BBS: Mac HTML information I was looking around on the cs320 page and noticied there were no references to any Macintosh WWW tools for writing HTML. I just found an EXCELLENT program for the Mac called Web Weaver 2.5.2. It is shareware though, but if you can try to find it on the internet if you need a Macintosh HTML editor. From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!math.ohio-state.edu!uwm.edu!lll-winken.llnl.gov!osi-east2.es.net!cronkite.nersc.gov!qiclab.scn.rain.com!pub.multnomah.lib.or.us!netnews3.nwnet.net!nwnet!netnews2.nwnet.net!starwave.com!news_admin@starwave.com Fri May 17 07:34:58 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!math.ohio-state.edu!uwm.edu!lll-winken.llnl.gov!osi-east2.es.net!cronkite.nersc.gov!qiclab.scn.rain.com!pub.multnomah.lib.or.us!netnews3.nwnet.net!nwnet!netnews2.nwnet.net!starwave.com!news_admin@starwave.com From: Carl Haynes Newsgroups: comp.lang.java Subject: Re: Applet Dialog boxes Date: Sun, 28 Apr 1996 21:46:03 -0700 Organization: Starwave Corporation Message-ID: <3184498B.3A5D@starwave.com> NNTP-Posting-Host: carlh.starwave.com Kevin Cutress wrote: > > I'm trying to create a dialog box in an applet. I want to read the info > that the user supplies through the dialog box, so I want to show the > dialog and wait for the user to make the approproate selections. I > assumed that making the dialog modal would do this since the docs say > that modal dialogs block input to the rest of the program. It doesn't > work that way. Any suggestions? Modal Dialogs aren't You need to handle the modal part yourself, I usually just set some flags to tell me that a modal dialog box is in from. Another way is to disable any panels in the applet when you bring the dialog up, this will prevent any input. To get the information back to the applet, just define an interface for the callback. for example in ScorePost I have a dialog observer interface that gets called when the user clicks on the ok or cancel button, passing back any necessary information. it looks something like this: public interface DialogObserver { public void dialogComplete(DialogData data, boolean saveChanges); } -- carl haynes, applet guy starwave corp -- http://www.starwave.com/people/haynes 206-957-2709 -- mailto:haynes@starwave.com -- I'll be at JavaOne May 29-31 From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!lll-winken.llnl.gov!osi-east2.es.net!cronkite.nersc.gov!qiclab.scn.rain.com!pub.multnomah.lib.or.us!netnews3.nwnet.net!nwnet!netnews2.nwnet.net!starwave.com!news_admin@starwave.com Fri May 17 07:35:39 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!lll-winken.llnl.gov!osi-east2.es.net!cronkite.nersc.gov!qiclab.scn.rain.com!pub.multnomah.lib.or.us!netnews3.nwnet.net!nwnet!netnews2.nwnet.net!starwave.com!news_admin@starwave.com From: Carl Haynes Newsgroups: comp.lang.java Subject: Re: how do you position frames? Date: Mon, 29 Apr 1996 01:55:25 -0700 Organization: Starwave Corporation Message-ID: <318483FD.27E0@starwave.com> NNTP-Posting-Host: carlh.starwave.com Thomas Wright wrote: > > When you create and show a frame ( for an application ), how do you > change the default drawing position from the top left of the screen? > > I would like to be able to position the frame in the center of the > screen, i sthis possable. > > Thanks for any help > > Tom Your looking for getToolkit().getScreenSize(); to center the frame do something like this: Dimension screenSize = getToolkit().getScreenSize(); int top = (screenSize.height / 2) - (dialogHeight / 2); int left = (screenSize.width / 2) - (dialogWidth / 2); theFrame.move(left, top); -- carl haynes, applet guy starwave corp -- http://www.starwave.com/people/haynes 206-957-2709 -- mailto:haynes@starwave.com -- I'll be at JavaOne May 29-31 From csus.edu!sacsa3.mp.usbr.gov!donews.do.usbr.gov!usbr.gov!csn!news-1.csn.net!magnus.acs.ohio-state.edu!math.ohio-state.edu!uwm.edu!news.sol.net!spool.mu.edu!munnari.OZ.AU!news.ecn.uoknor.edu!solace!xinit!newsfeed.tip.net!news.seinf.abb.se!news.mdh.se!columba.udac.uu.se!mac136-35.tdb.uu.se!user Fri May 17 08:22:38 1996 Path: csus.edu!sacsa3.mp.usbr.gov!donews.do.usbr.gov!usbr.gov!csn!news-1.csn.net!magnus.acs.ohio-state.edu!math.ohio-state.edu!uwm.edu!news.sol.net!spool.mu.edu!munnari.OZ.AU!news.ecn.uoknor.edu!solace!xinit!newsfeed.tip.net!news.seinf.abb.se!news.mdh.se!columba.udac.uu.se!mac136-35.tdb.uu.se!user From: karl@tdb.uu.se (Karl Hornell) Newsgroups: comp.lang.java Subject: Re: Array -> Image ? Date: Wed, 08 May 1996 08:37:41 +0100 Organization: TDB, Uppsala University Message-ID: NNTP-Posting-Host: mac136-35.tdb.uu.se X-Newsreader: Yet Another NewsWatcher 2.1.8 In article <4mo61q$f9r@brachio.zrz.TU-Berlin.DE>, wolfcdia@w350zrz.zrz.TU-Berlin.DE (Sabine Wolf) wrote: >Hi! :) >My applet creates every 1-2 seconds a new pattern of the size 40*40 pixel >and draws the pixel on the screen with lot of fillRect comands. >It works fine on the Indigo but its to slow on the Mac. >Is there a way to write the image data in an array and then to copy the array >into the image or direct on the screen , like QuickBasic does it with the >PUT command ? If you keep the pixel color info (as RGB values) in an array of 1600 integers, then Image my_image = createImage(new MemoryImageSource(40,40,my_array,0,40)); will create a 40x40 image you can draw on the screen the size you want, using the Graphics.drawImage method. Karl H. karl@tdb.uu.se kxh27@po.cwru.edu From csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!news.uoregon.edu!vixen.cso.uiuc.edu!newsfeed.internetmci.com!realtime.net!fence Sat May 18 11:52:30 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!news.uoregon.edu!vixen.cso.uiuc.edu!newsfeed.internetmci.com!realtime.net!fence From: robert@bga.com (Robert Cope) Newsgroups: comp.lang.java Subject: Re: JDK 1.02 Fixes Canvas random painting!! Date: Tue, 07 May 96 18:42:50 GMT Organization: Zero Factor Interactive Message-ID: <4mo5pp$fog@news3.realtime.net> NNTP-Posting-Host: apm1-68.realtime.net X-RTcode: 4887d4b83179a1694c8f9a3c X-Newsreader: News Xpress 2.0 Beta #0 In article <318F9016.350B@otherwise.com>, Bill Tschumy wrote: >The default background for Frames has changed from Color.lightGray to >Color.white. If you want a lightGray background you must set it >explicitly. Actually, the default background is now inherited from the current desktop colors. In any case, you must now set it yourself if you want it to be lightGray. robert Robert Cope || Zero Factor Interactive - Web design, Java robert@bga.com || info@zfi.com development, Shockwave, || http://www.zfi.com VRML, etc. From csus.edu!dick Sat May 18 11:53:52 1996 Path: csus.edu!dick From: dick@silicon.csci.csusb.edu (Dr. Richard Botting) Newsgroups: comp.lang.java Subject: Re: Apps for which Java is not suitable? Date: 17 May 1996 15:38:19 GMT Organization: CS Dept., Calif. State Univ., San Bernardino Message-ID: <4ni6hb$9n1@news.csus.edu> NNTP-Posting-Host: dick%@blaze.csci.csusb.edu X-Newsreader: TIN [version 1.2 PL2] : : writes: : : >I gave a little talk recently on early CS curriculum, in which : : >I said favorable things about Java, having been turned on by : : >what I heard at the Sun Education and Research Conference last : : >week. Afterward an audience member said that there are apps for : : >which OO methods make no sense, such as some kinds of graphics [snip] The speaker may not know that OO techniques were put to use in graphical systems (Smalltalk, SketchPad, MacDraw,...) before it became popular elsewhere. For my humble opinion.... Don't use Java for: (1) Any area where the cost of a change in the underlying language is going to kill the project. Java has been reinvented too much. In 5 years time: maybe. When it is an ANSI/ISO standard: yes. (2) Any application which is potentially life threatening. It may be better than assembler, C, C++, etc but this is not saying much. In fact I'd think twice about any mission-critical application. Since things like the New York Long Distance shutdown are as likely in Java as they were in C. (3) Any application that handles my money:-). -- dick botting http://www.csci.csusb.edu/dick/signature.html Disclaimer: CSUSB may or may not agree with this message. Copyright(1996): Copy freely but say where it came from. I have nothing to sell, and I'm giving it away. From csus.edu!csulb.edu!BellSouth!news.cc.emory.edu!cssun.mathcs.emory.edu!swrinde!howland.reston.ans.net!EU.net!usenet1.news.uk.psi.net!uknet!pub.news.uk.psi.net!usenet Sun May 19 08:19:04 1996 Path: csus.edu!csulb.edu!BellSouth!news.cc.emory.edu!cssun.mathcs.emory.edu!swrinde!howland.reston.ans.net!EU.net!usenet1.news.uk.psi.net!uknet!pub.news.uk.psi.net!usenet From: Lloyd Blythen Newsgroups: comp.lang.java Subject: Re: Cant find class Hello Date: Sat, 11 May 1996 15:14:45 +0100 Organization: Not much Message-ID: <3194A0D5.6AF4@aptdata.co.uk> NNTP-Posting-Host: lloydb.aptdata.co.uk > I made the hello.class from the hello.java file > class HelloWord { > public static void main (String args[]) { > System.out.println("Hello world!"); > } > } > javac hello.java > the output is hello.class > Now it wont run: > Cant find class hello > What's wrong here? Classic gotcha, Martin - happened to me too. The interpreter expects the file "hello.class" to contain a class called "hello"; your class is called "HelloWord". A point: assuming you meant "HelloWorld", you might have a minor typo as well. Lloyd From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!newsfeed.internetmci.com!news.mathworks.com!uunet!in1.uu.net!shore!mv!usenet Sun May 19 08:50:28 1996 Newsgroups: comp.lang.java Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!newsfeed.internetmci.com!news.mathworks.com!uunet!in1.uu.net!shore!mv!usenet From: joe@millar.mv.com (Joseph Millar) Subject: Re: Java 1.0.2 out Message-ID: Organization: MV Communications, Inc. Date: Thu, 16 May 1996 21:01:30 GMT X-Newsreader: Forte Free Agent 1.0.82 X-Nntp-Posting-Host: jmillar-1.ftp.com "P.V.Subramanian" wrote: > Hi, > Re: 1.0.2 can someone tell me the ftp URL to > the place where I can find the html > documentation for the JDK 1.0.2 API. I > believe it is available as a single file, > which I can unzip locally. Try: ftp://ftp.javasoft.com/docs/JDK-1_0_2-apidocs.sea.bin ftp://ftp.javasoft.com/docs/JDK-1_0_2-apidocs.sea.hqx ftp://ftp.javasoft.com/docs/JDK-1_0_2-apidocs.tar.Z ftp://ftp.javasoft.com/docs/JDK-1_0_2-apidocs.zip --Joe __________________________________________________________________ Joseph A. Millar "Very funny, Scotty! Now beam down my clothes!" - James T. Kirk From csus.edu!sacsa3.mp.usbr.gov!donews.do.usbr.gov!usbr.gov!csn!nntp-xfer-1.csn.net!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!newsfeed.internetmci.com!in2.uu.net!news.abs.net!aplcenmp!hall Sun May 19 08:51:04 1996 Newsgroups: comp.lang.java Path: csus.edu!sacsa3.mp.usbr.gov!donews.do.usbr.gov!usbr.gov!csn!nntp-xfer-1.csn.net!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!newsfeed.internetmci.com!in2.uu.net!news.abs.net!aplcenmp!hall From: hall@aplcenmp.apl.jhu.edu (Marty Hall) Subject: Re: JDK 1.02 Strange Changes Message-ID: Organization: JHU/APL Research Center, Hopkins P/T CS Faculty Date: Thu, 9 May 1996 13:13:45 GMT In article <4mr8k7$201@news.jf.intel.com> sherm@ibeam.jf.intel.com writes: >For the Java JDK 1.0 and 1.01 I did a lot of: > >try > SomeStream.close(); >catch (Exeception e) > System.out.println("error"); > >Now in release 1.02 brackets are needed: > >try { > SomeStream.close(); >} catch (Exeception e) { > System.out.println("error"); >} > >Why does 1.02 specifically require the blocks? I thought that the language spec *always* said you need the brackets, but that some implementations failed to enforce this. Plus, the otherwise outstanding _Java in a Nutshell_ gives lots of examples without the brackets. - Marty Java Resources: From csus.edu!csulb.edu!BellSouth!news.iag.net!news.math.psu.edu!news.cse.psu.edu!uwm.edu!lll-winken.llnl.gov!nntp.coast.net!zombie.ncsc.mil!news.mathworks.com!newsfeed.internetmci.com!newsxfer2.itd.umich.edu!agate!boulder!sherod Tue May 21 15:13:38 1996 Path: csus.edu!csulb.edu!BellSouth!news.iag.net!news.math.psu.edu!news.cse.psu.edu!uwm.edu!lll-winken.llnl.gov!nntp.coast.net!zombie.ncsc.mil!news.mathworks.com!newsfeed.internetmci.com!newsxfer2.itd.umich.edu!agate!boulder!sherod From: sherod@newton.Colorado.EDU (Scott Herod) Newsgroups: comp.lang.java Subject: Re: make Date: 12 May 1996 18:55:05 GMT Organization: /usr/local/lib/rn/organization Message-ID: <4n5c69$7sd@lace.colorado.edu> NNTP-Posting-Host: newton.colorado.edu NNTP-Posting-User: sherod The following works for me: =============================== newton % cat Makefile .SUFFIXES: .java .class .java.class: javac $< FILES = Syntax_error.class all: $(FILES) newton % make all javac Syntax_error.java newton % ================================ In article <3195E65F.41C6@arch.ethz.ch> Rudi Stouffs writes: >i wanted to write a makefile to compile my java files, >but make wouldn't recognize a .java.class rule. >does anyone now if java support exists for make >or what i may need to do. >currently i get around with a separate line for each file, >but that kind of beats the whole idea of using make. >thanks, >-rudi > From csus.edu!csulb.edu!BellSouth!news.iag.net!news.math.psu.edu!news.cse.psu.edu!uwm.edu!math.ohio-state.edu!howland.reston.ans.net!newsfeed.internetmci.com!info.ucla.edu!library.ucla.edu!agate!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!news.ox.ac.uk!sable.ox.ac.uk!lady0065 Tue May 21 15:21:53 1996 Path: csus.edu!csulb.edu!BellSouth!news.iag.net!news.math.psu.edu!news.cse.psu.edu!uwm.edu!math.ohio-state.edu!howland.reston.ans.net!newsfeed.internetmci.com!info.ucla.edu!library.ucla.edu!agate!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!news.ox.ac.uk!sable.ox.ac.uk!lady0065 From: lady0065@sable.ox.ac.uk (David Hopwood) Newsgroups: comp.lang.java Subject: Re: Java has no call by reference. Why this is a good thing. Date: 13 May 1996 07:48:55 GMT Organization: Oxford University, England Message-ID: <4n6ph7$jsk@news.ox.ac.uk> NNTP-Posting-Host: sable.ox.ac.uk In article <01bb407e.dba68180$05acafc6@notware.psyton.com>, Robert Herrmann wrote: > >On Sunday, May 12, 1996, Alexander Anderson wrote... >> int a= 7; >> int b= 16; >> swap(a, b); >> ??? > >Its worth noting (or making clear) that although the above routine could >not ever perform the swap correctly, the following version could. > >Integer a = new Integer( 7 ); >Integer b = new Integer( 16 ); > >swap(a,b); No it couldn't. (This 'solution' to passing references to primitive values seems to be gaining something of the status of an urban myth.) The wrapper classes in java.lang are immutable; you cannot change the wrapped value after creation, nor can you inherit from them. To do something equivalent, you have to create your own wrapper classes which have a method to set the current value. I've written a set of these; they're called IntegerBuffer, etc. (in analogy with String and StringBuffer). If you don't want to write your own, I'll be releasing them at the same time as the extensions to support dynamic method look-up. David Hopwood david.hopwood@lmh.ox.ac.uk From csus.edu!csusac!charnel.ecst.csuchico.edu!xmission!newsfeed.direct.ca!news.wildstar.net!cancer.vividnet.com!hunter.premier.net!bofh.dot!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!demos!solace!umdac!newsfeed.sunet.se!news01.sunet.se!sunic!news99.sunet.se!news.uni-c.dk!news.daimi.aau.dk!gnort Tue May 21 15:22:40 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!xmission!newsfeed.direct.ca!news.wildstar.net!cancer.vividnet.com!hunter.premier.net!bofh.dot!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!demos!solace!umdac!newsfeed.sunet.se!news01.sunet.se!sunic!news99.sunet.se!news.uni-c.dk!news.daimi.aau.dk!gnort From: Lars Balker Rasmussen Newsgroups: comp.lang.java Subject: Re: Java has no call by reference. Why this is a good thing. Date: 13 May 1996 18:11:24 +0200 Organization: DAIMI, Computer Science Dept. of Aarhus Univ. Message-ID: <0fbujs7dub.fsf@fraxinus.daimi.aau.dk> NNTP-Posting-Host: fraxinus.daimi.aau.dk X-Newsreader: September Gnus v0.83/Emacs 19.30 Alexander Anderson writes: > Someone, how do you write a SWAP method in Java? > > You know, you've got two int variables and you want to swap the > values. I want to know how to do this easily looking like: > > int a= 7; > int b= 16; > swap(a, b); Ah that one is easy. You can't. You can do this, though. public class test { static void swap(int[] r) { int t = r[0]; r[0] = r[1]; r[1] = t; } public static void main(String args[]) { int[] arr = { 7, 16 }; swap(arr); System.out.println("a: " + arr[0] + " b: " + arr[1]); } } -- Lars Balker Rasmussen C++ is a ridiculously complicated travesty that few have the excess IQ points to understand enough not to screw up massively. --Tom Christiansen From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!news.be.innet.net!bofh.dot!INbe.net!news.nl.innet.net!INnl.net!hunter.premier.net!bofh.dot!news.mathworks.com!news.kei.com!nntp.coast.net!torn!watserv3.uwaterloo.ca!undergrad.math.uwaterloo.ca!j2lynn Tue May 21 15:23:17 1996 Newsgroups: comp.lang.java Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!howland.reston.ans.net!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!news.be.innet.net!bofh.dot!INbe.net!news.nl.innet.net!INnl.net!hunter.premier.net!bofh.dot!news.mathworks.com!news.kei.com!nntp.coast.net!torn!watserv3.uwaterloo.ca!undergrad.math.uwaterloo.ca!j2lynn From: j2lynn@undergrad.math.uwaterloo.ca (James F'jord Lynn) Subject: Re: Java has no call by reference. Why this is a good thing. Message-ID: Date: Mon, 13 May 1996 19:57:28 GMT Nntp-Posting-Host: noether.math.uwaterloo.ca Organization: University of Waterloo In article , Alexander Anderson wrote: > Wouldn't you rather use Miranda or Haskell? > Someone, how do you write a SWAP method in Java? Well, if you really need it all on one line, and they are not of the float family, you could always do a^=b^=a^=b; //swap(a,b); but without a preprocessor, this can be unweildy (and with a preprocessor, prone to bugs). -- Life - F'jord of Timelord, James Lynn Java - http://www.undergrad.math.uwaterloo.ca/~j2lynn/java.html SuperButton v1.1 and MessageBox v1.0 available there From csus.edu!csulb.edu!BellSouth!news.iag.net!news.worldpath.net!imci3!imci4!newsfeed.internetmci.com!in2.uu.net!EU.net!sun4nl!cs.ruu.nl!usenet Tue May 21 15:37:10 1996 Path: csus.edu!csulb.edu!BellSouth!news.iag.net!news.worldpath.net!imci3!imci4!newsfeed.internetmci.com!in2.uu.net!EU.net!sun4nl!cs.ruu.nl!usenet From: Casper Lans Newsgroups: comp.lang.java Subject: Re: How Does Casting Work? Date: Mon, 13 May 1996 13:46:54 +0200 Organization: Universiteit Utrecht, Dept. of Computer Science Message-ID: <3197212E.7657@cs.ruu.nl> NNTP-Posting-Host: winter.cs.ruu.nl calvin wrote: > > How does casting work. > > Here is the code: > > System.out.println(((Scrollbar)e.target).getvalue()); > > What is this piece of code doing. Is scrollbar a instance variable in > e.target. Because the target of an Event can be a different objects, it is declared as I think an Object or a Component. Lets assume it is an Object. So Event.target can reference an Object or a subclass of Object (that means it can reference an object of any class, because all classes are subclasses of Object). So e.target could reference to a Scrollbar object, but the compiler doesn't know that because e.target is declared as an Object. So if you would call e.target.getValue(), the compiler would look for the method Object.getValue(), which doesn't exist. So in order to call the method Scrollbar.getValue(), you have to tell the compiler that e.target is a Scrollbar. To do this you have to cast the Object e.target into a Scrollbar using: (Scrollbar) e.target. To tell the compiler that you want to cast e.target and not e.target.getValue(), you have to use the extra ()'s: ((Scrollbar)e.target).getValue() and NOT: (Scrollbar)e.target.getValue(). > > Ok, another example: > > public boolean action (Event e, Object o){ > if (e.target instanceof Button) { > String label = (String)o; The same here: label is a String, so it can not reference an Object, that's why you'll have to tell the compiler that o is a String by casting o into a String using: (String)o. -- \|/ (o o) --oOO-(_)-OOo-- Casper Lans cdlans@cs.ruu.nl From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!howland.reston.ans.net!Germany.EU.net!wizard.pn.com!brighton.openmarket.com!decwrl!pa.dec.com!depot.mro.dec.com!mrnews.mro.dec.com!news Tue May 21 15:42:58 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!howland.reston.ans.net!Germany.EU.net!wizard.pn.com!brighton.openmarket.com!decwrl!pa.dec.com!depot.mro.dec.com!mrnews.mro.dec.com!news From: George Paci Newsgroups: comp.lang.java Subject: Re: Why are months zero based? Date: Thu, 16 May 1996 12:26:01 -0400 Organization: Digital Semiconductor Message-ID: <319B5719.4FDD@bigq.hlo.dec.com> <3198D100.337D@uh.edu> <4nbfgj$eba@news.mel.aone.net.au> <4ncvu4$dqe@oblivion.utdallas.edu> Reply-To: paci@bigq.hlo.dec.com NNTP-Posting-Host: chang1.hlo.dec.com Glenn Vanderburg wrote: > btate@pfms.com.au (Bradley Tate) writes: > > Don't you think this misses the point, though? How much trouble is it > > to allocate an array with 13 month names the zeroeth being blanks or > > whatever. [snip] > Hmm. It's more trouble to allocate an array with 13 months in it than > it is to remember that the month value is zero-based, especially since > everything else in the language is zero-based as well. We're programmers. > When we count, we start from zero. Simple. > ---glv There are two related but distinct issues here: 1) Java's internal representation of dates starts numbering months at 0. 2) Java's built-in date-parsing *also* starts numbering the months at 0, even though every string format for dates that I've ever seen either starts numbering them at 1 or represents them non-numerically. (1) doesn't really bother me, though it doesn't add much in the way of convenience, either (I mean, come on: how much further away is "3" than "2" on *your* keyboard?). (2) is a royal pain in the ass, and I wish they'd either change it (difficult now with the installed code base) or add a flag to the parsing routine to tell it that 1 means January, damn it. (While they're at it, they could add an American/European flag to disambiguate "4/3/96".) Because of (2), I had to either a) reimplement date parsing, which is mostly grunt work with plenty of opportunities for subtle errors, or b) try to recognize when months are represented numerically, and hack around Java's parsing. I chose (b); while it works on a well-selected set of test cases, it's still an ugly hack. And I do consider (2) a bug: when you feed a program "3/31/96" and it interprets it as "May 1, 1996", that's behavior no reasonable person would expect. There's a standard for numeric representation of months (January==1), and Java violates it. Anyway, I've attached my ugly hack for those of you who need to parse dates that may be in a variety of formats. --George Paci, speaking only for himself. ---------------- begin USDate.java ------------- // USDate: // A subclass of Date that correctly interprets date strings // of the form MM/DD/YY (by comparison, Date thinks 4/17/71 // is *May* 17, 1971 -- it numbers months starting from 0). // Restrictions: // * *Must* start a MM/DD/YY input string with a digit, // otherwise USDate doesn't recognize the format, and // lets Date do its (incorrect) thing. // * Can't give constructor a String that Date wouldn't take; // among other things, this means nothing with year before // 1970 or after about 2037; this also means you can only // specify two-digit years from 70 through 99, after which // you have to go to four digits (..., 98, 99, 2000, 2001, ...). // * You can give times in the MM/DD/YY HH:MM:SS format, but // make sure they're in bounds, or unpredictable stuff could // happen to the days and months. //import java.util.Date; import java.io.*; class USDate extends java.util.Date { // override the Date constructor that takes a string: public USDate(String s) { // Let Date do its thing: super(s); if (Character.isDigit(s.charAt(0))) { // starts with a digit, so it must be MM/DD/YY[YY] format; // adjust the month accordingly: int c = 0; int month = 0; int day = 0; int year = 0; StringBuffer sb = new StringBuffer(5); StringBufferInputStream is = new StringBufferInputStream(s); // get the month: for(sb.setLength(0); (c = is.read()) != -1 && Character.isDigit((char) c); ) sb.append((char) c); try { month = Integer.valueOf(sb.toString()).intValue(); } catch (NumberFormatException e) { System.err.println("USDate: couldn't read month: " + e); } if ((month < 1) || (month > 12)) { System.err.println("USDate: month out of range: " + month); return; } // make the month conform to Date's semantics: --month; // make sure we have the right delimiter: if ((char) c != '/') { System.err.println("USDate: expected / after month; got: " + (char) c); return; } // get the day: for(sb.setLength(0); (c = is.read()) != -1 && Character.isDigit((char) c); ) sb.append((char) c); try { day = Integer.valueOf(sb.toString()).intValue(); } catch (NumberFormatException e) { System.err.println("USDate: couldn't read day: " + e); } if ((day < 1) || (day > 31)) { System.err.println("USDate: day out of range: " + day); return; } // Date will automatically deal with days too big for their month. // make sure we have the right delimiter: if ((char) c != '/') { System.err.println("USDate: expected / after day; got: " + (char) c); return; } // get the year (expect YY format or YYYY format): for(sb.setLength(0); (c = is.read()) != -1 && Character.isDigit((char) c); ) sb.append((char) c); try { year = Integer.valueOf(sb.toString()).intValue(); } catch (NumberFormatException e) { System.err.println("USDate: couldn't read year: " + e); } if (year < 0) { System.err.println("USDate: year out of range: " + year); return; } else if (year >= 1900) // we got YYYY; convert it to Date's semantics: year -= 1900; // update the date with this info: setYear(year); setMonth(month); setDate(day); } } // leave the other constructors alone: public USDate() { super(); } public USDate(long date) { super(date); } public USDate(int year, int month, int date) { super(year, month, date); } public USDate(int year, int month, int date, int hrs, int min) { super(year, month, date, hrs, min); } public USDate(int year, int month, int date, int hrs, int min, int sec) { super(year, month, date, hrs, min, sec); } } -------------- end USDate.java ------------- From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cssun.mathcs.emory.edu!news-feed-1.peachnet.edu!usenet.eel.ufl.edu!bofh.dot!news.mathworks.com!news.kei.com!nntp.coast.net!torn!watserv3.uwaterloo.ca!undergrad.math.uwaterloo.ca!j2lynn Tue May 21 16:32:56 1996 Newsgroups: comp.lang.java Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cssun.mathcs.emory.edu!news-feed-1.peachnet.edu!usenet.eel.ufl.edu!bofh.dot!news.mathworks.com!news.kei.com!nntp.coast.net!torn!watserv3.uwaterloo.ca!undergrad.math.uwaterloo.ca!j2lynn From: j2lynn@undergrad.math.uwaterloo.ca (James F'jord Lynn) Subject: Re: Java *has* call by reference. Why this is a good thing. Message-ID: Date: Mon, 13 May 1996 19:50:30 GMT Nntp-Posting-Host: noether.math.uwaterloo.ca Organization: University of Waterloo In article <319677E4.71A6@mines.edu>, Danno Ferrin wrote: >Obviously you haven't been programing in java very long or have been passing >only primatives as parameters. Whenever anyhting derived from Object is >passed as a aprameter, it is passed by refrence, anwalys and (currently) >without exception. Objects can be passed by value if you send >myObject.clone(), but only if (myObject instanceof Clonaeble) == true. There >is a keyword reserved to allow passing "byvalue." Actually, a more accurate description would be, the Objects in java are all references that are passed by value. The reason why Objects cannot be considered as being passed by reference is illustraited in the following code: public class ValueVSReference { void foo(String bar) { bar=new String("Pass by reference"); } static void main(String args[]) { String theJudge="Pass by value"; foo(theJudge); System.out.println(theJudge); } } And what does theJudge say? Pass by value -- Life - F'jord of Timelord, James Lynn Java - http://www.undergrad.math.uwaterloo.ca/~j2lynn/java.html SuperButton v1.1 and MessageBox v1.0 available there From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!news.msfc.nasa.gov!news.larc.nasa.gov!night.primate.wisc.edu!aplcenmp!hall Tue May 21 16:34:28 1996 Newsgroups: comp.lang.java Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!news.msfc.nasa.gov!news.larc.nasa.gov!night.primate.wisc.edu!aplcenmp!hall From: hall@aplcenmp.apl.jhu.edu (Marty Hall) Subject: Re: Java *has* call by reference. Why this is a good thing. Message-ID: Organization: JHU/APL Research Center, Hopkins P/T CS Faculty Date: Thu, 16 May 1996 13:36:52 GMT In article <319677E4.71A6@mines.edu> Danno Ferrin writes: >Whenever anyhting derived from Object is >passed as a aprameter, it is passed by refrence, anwalys and (currently) >without exception. Here we go again. Java uses only "call by value" argument passing. Never "call by reference". This means that if you call foo(x) and foo is is something like SomeClass foo(AnotherClass a) { a = somethingElse(); ... } then x will *not* change. It would with call by reference. What makes this confusing is that Java uses the term "reference" for what it passes for the values of non-primitive objects (ie "references" here are pointers with restricted types of operations). Whether Java uses call by reference or call by value is independent of the kinds of values Java uses. Point: "call by reference" and Java "references" are two different things. - Marty Java Resources: From csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!samba.rahul.net!rahul.net!a2i!bug.rahul.net!rahul.net!a2i!genmagic!sgigate.sgi.com!uhog.mit.edu!news.mathworks.com!newsfeed.internetmci.com!bloom-beacon.mit.edu!lard.ftp.com!news-control Tue May 21 17:05:22 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!samba.rahul.net!rahul.net!a2i!bug.rahul.net!rahul.net!a2i!genmagic!sgigate.sgi.com!uhog.mit.edu!news.mathworks.com!newsfeed.internetmci.com!bloom-beacon.mit.edu!lard.ftp.com!news-control From: jmillar@ftp.com (Joseph Millar) Newsgroups: comp.lang.java Subject: Re: Help with Java Homework! Date: Mon, 13 May 1996 17:18:40 GMT Organization: FTP Software, Inc. Message-ID: <4n7rf9$jts@lard.ftp.com> NNTP-Posting-Host: jmillar-2.ftp.com X-Newsreader: Forte Free Agent 1.0.82 rgelb@csulb.edu (Robert Gelb) wrote: > I am new to Java and I have source code but I can't get it to compile and > run. I have an Account class which includes a balance variable, a > constructor and 2 methods (deposit and getBalance). Then I have a class > UseAccount, which is there basically to execute and test Account class. > It has only one method - main. As you can see below, I have written both > classes, but I am not sure how to get it to work. Should I put one class > into one file and another class into another file? Anyways, here is the > source code for my project. > I am not trying to do an applet, just a stand-alone app is fine. > And also, if someone could let me know, how to compile and link it. > should it be : java UseAccount.java or java Account.java??? [snip!] You've got a couple options here in terms of class placement: 1. Put both classes in one file, name the file the same as the class that has the main() method, and make all other classes non-public. You can have as many classes as you want in a file, but only one public class is allowed. It should be the one which has the main() method. When you compile this: javac UseAccount.java the compiler produces 2 .class files, one for each class in the source, so from your code you should get: UseAccount.class Account.class Just call "java UseAccount" to run it. Simple. 2. If you plan on using a particular class in several different places (code reuse is a good thing, IMHO), place that class in its own file and make it public. You'll now have to compile 2 source files (or use javac *.java), but it breaks large projects up into managable pieces. When you compile the class that uses this one, javac will look in CLASSPATH to find it so make sure you have either the current directoy (".") or whereever in CLASSPATH. To compile: javac Account.java (produces Account.class) javac UseAccount.java (produces UseAccount.class) To run: java UseAccount For small, simple projects, I'd use #1, but for larger projects #2 is much more versatile. Hope this helps...Joe ___________________________________________________________________ Joseph A. Millar FTP Software, Inc. Software Engineer Ph: (508) 684-6461 100 Brickstone Square jmillar@ftp.com Fax:(508) 684-6992 Andover, MA 01810 http://www.ftp.com USA From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!metro!metro!inferno.mpx.com.au!alex Tue May 21 17:07:15 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!metro!metro!inferno.mpx.com.au!alex From: alex@access.com.au (Alexandre Rafalovitch) Newsgroups: comp.lang.java Subject: Re: Help- drawImage causes a flood of updates! - AHA! Date: Tue, 14 May 1996 15:09:51 +1000 Organization: Access Research Systems Message-ID: NNTP-Posting-Host: 203.18.229.116 X-Newsreader: Yet Another NewsWatcher 2.2.0b7 In article <31968A3D.7FF5@itsnet.com>, Red Brian wrote: >I found the problem. I was using the media tracker to force the loading >of a large gif file that was composed of a bunch of little images. Then >I was using a cropImage filter to break it up into little images for >display on the screen. It turned out that the cropping wasn't occurring >until I actually tried to display the little images. > >So, the display of a piece would cause the crop to occur, which would >cause a repaint, then the next piece displayed would cause the crop to >occur, which would cause a repaint. Since I had ~20 images I would get >20 repaints. Ugh. > >Using the media tracker around the crops forced them to occur and fixed >the update flood on startup. > Actually, if you only used cropImage to break small images from one big one, you could use clipRectangle/paint(-xoffset, -yoffset..) trick. It is much faster and does not need the second mediaTracker. Good example of this trick is Rotator applet. This trick was also mentioned in number of places. I can provide more details if required, but search on Rotator in Gamelan should be enough. Hope it helps, Alex. >Be forewarned :). Thanks for warning, it can be usefull with other filters. From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!howland.reston.ans.net!newsfeed.internetmci.com!panix!not-for-mail Thu May 23 17:20:42 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!howland.reston.ans.net!newsfeed.internetmci.com!panix!not-for-mail From: David Koosis Newsgroups: comp.lang.java Subject: Re: java.util.date Date: 20 May 1996 12:00:40 -0400 Organization: ISC Consultants Inc. Message-ID: <4nq4v8$t6f@panix.com> Reply-To: David Koosis NNTP-Posting-Host: panix.com In <3190E204.167EB0E7@motown.ge.com> "Ted M. Troccola" writes: >I get exceptions raised when I use > Date d = new Date(01, 2, 23); >Actually, any year < 70 fails! >Is there a reason for this? How would you put June 10, 1950 in? 1970 is UNIX year zero. Time/Date values are stored as milliseconds since Jan 1 1970. The upper limit is 31 December 2037. To tell the truth I'm not sure exactly why the range is so small. The date range supported is about... 67 * 365 * 24 * 60 * 60 * 1000 = 2,112,912,000,000 milliseconds This is bigger than an int and smaller than a long. A good source of answers to these kinds of questions is JavaSoft's "Known Bugs and Frequently Requested Features" page for Java: http://www.javasoft.com/java.sun.com/bugsandfeatures.html Increasing the range of valid Date values is a requested feature: Request to increase the range of valid Date class values from the current range of 1-Jan-1970 to 31-Dec-2037 to a range of at least 1-Jan-0001 to 31-Dec-9999. (1234739) //dk From csus.edu!csulb.edu!BellSouth!news.cc.emory.edu!cssun.mathcs.emory.edu!swrinde!howland.reston.ans.net!cs.utexas.edu!ennfs.eas.asu.edu!noao!CS.Arizona.EDU!newsham Thu May 23 17:31:44 1996 Path: csus.edu!csulb.edu!BellSouth!news.cc.emory.edu!cssun.mathcs.emory.edu!swrinde!howland.reston.ans.net!cs.utexas.edu!ennfs.eas.asu.edu!noao!CS.Arizona.EDU!newsham From: newsham@GAS.UUG.Arizona.EDU (Timothy N. Newsham) Newsgroups: comp.lang.java Subject: Re: Why are months zero based? Date: 22 May 1996 16:51:02 GMT Organization: U of Arizona, CS Dept, Tucson Message-ID: <4nvglm$boh@optima.cs.arizona.edu> NNTP-Posting-Host: lectura.cs.arizona.edu X-Newsreader: TIN [version 1.2 PL2] Bradley Tate (btate@c01.aone.net.au) wrote: : Could someone please explain to me why the months in java.util.date : start from 0 instead of 1? I am at a loss to understand why this has : been done, or at least why it has been presented to the world in this : form. If the designers want to do this internally, fine, but I : understood there was a convention in the real world of January being : month 1, February month 2 etc. quite simple really: Thats the way it is done in C (see /usr/include/time.h and java/util/Date.java: the similarity to struct tm is more than coincidental). So the real question: why did they do that in C? Well you would normally print the date as: printf("%s %d\n", month_name[month_index], day_of_month); so it is convenient to have the month_index starting at zero but your day_of_month left one based. : If there is a really, really good reason for this I'd love to hear it. I wouldn't say "really good". : Regards, : Bradley Tate From csus.edu!csusac!zimmer.CSUFresno.EDU!newshub.csu.net!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!newsfeed.internetmci.com!news.kei.com!nntp.coast.net!inquo!bofh.dot!news.seinf.abb.se!erinews.ericsson.se!newsfeed.sunet.se!news01.sunet.se!sunic!news99.sunet.se!news.uni-c.dk!news.daimi.aau.dk!gnort Thu May 23 18:00:37 1996 Path: csus.edu!csusac!zimmer.CSUFresno.EDU!newshub.csu.net!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!newsfeed.internetmci.com!news.kei.com!nntp.coast.net!inquo!bofh.dot!news.seinf.abb.se!erinews.ericsson.se!newsfeed.sunet.se!news01.sunet.se!sunic!news99.sunet.se!news.uni-c.dk!news.daimi.aau.dk!gnort From: Lars Balker Rasmussen Newsgroups: comp.lang.java Subject: Re: Whats Wrong With This?? Date: 13 May 1996 19:50:15 +0200 Organization: DAIMI, Computer Science Dept. of Aarhus Univ. Message-ID: <0f3f54799k.fsf@fraxinus.daimi.aau.dk> NNTP-Posting-Host: fraxinus.daimi.aau.dk X-Newsreader: September Gnus v0.83/Emacs 19.30 threezs@aol.com (ThreeZs) writes: > javac -g sigtest.java > compiling: sigtest.java > Error: c:\MyJava\sigtest.java(78): Statement not reached. > double D0= 0.00233520497626869185443; > I have spent at least 8 hours trying to work this out without success and > I need some fresh eyes or a warning about Javac. > > TIA > private double Derf(double XX) { [31 vars deleted] > double D0= 0.00233520497626869185443; Hmmm, that's funny. Could that be related to this known bug? Compiler will not compile a method with more than 63 local variables. The javac compiler will not compile any method with more than 63 local variables. The minimum acceptable upper bound on local variables has yet to be defined. (1240530) Try putting the constants in an interface and implement that, like this: ---------------------------------------------------------------------- interface Consts { static final double CN = 0.5641895835477563; static final double A0 = 1230.33935479799725272; [the rest of your constants here] static final double Q4 = 1.000000000000000000000; } class sigtest implements Consts { ---------------------------------------------------------------------- I tried it and it compiled fine. -- Lars Balker Rasmussen C++ is a ridiculously complicated travesty that few have the excess IQ points to understand enough not to screw up massively. --Tom Christiansen From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cssun.mathcs.emory.edu!gatech!usenet.eel.ufl.edu!bofh.dot!news.mathworks.com!news.kei.com!nntp.coast.net!torn!watserv3.uwaterloo.ca!undergrad.math.uwaterloo.ca!j2lynn Thu May 23 18:04:50 1996 Newsgroups: comp.lang.java Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cssun.mathcs.emory.edu!gatech!usenet.eel.ufl.edu!bofh.dot!news.mathworks.com!news.kei.com!nntp.coast.net!torn!watserv3.uwaterloo.ca!undergrad.math.uwaterloo.ca!j2lynn From: j2lynn@undergrad.math.uwaterloo.ca (James F'jord Lynn) Subject: Re: How do you implement SWAP without call by reference? Message-ID: Date: Mon, 13 May 1996 20:09:30 GMT Nntp-Posting-Host: noether.math.uwaterloo.ca Organization: University of Waterloo In article <4n6km7$jp2@news2.delphi.com>, Roedy Green wrote: >Alexander Anderson wrote: > >Here is a more Javaesque solution: > class Pair { > int first; > int second; > > Pair (int first, int Second) { this.first = first; this.second = second; } > > static Pair Swap(Pair p) { > return new Pair (p.second, p.first ); > } > } > >To use it: > Pair q = new Pair(5,10); > q = swap(q); The problem with this is that a swap function is really only useful on Lvalues (okay, in parsing it can be useful for non Lvalues), and so you might as well use a temp variable since after creating your Pair class, swapping and reassigning the pair class, you must asign the swapped values to the Lvalues you were originally going to assign to. Just my (int)Math.E cents. -- Life - F'jord of Timelord, James Lynn Java - http://www.undergrad.math.uwaterloo.ca/~j2lynn/java.html SuperButton v1.1 and MessageBox v1.0 available there From csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!grapevine.lcs.mit.edu!newsie.dmc.com!news.sprintlink.net!cerberus.fon.sprintcorp.com!news Sat Mar 9 09:41:13 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!grapevine.lcs.mit.edu!newsie.dmc.com!news.sprintlink.net!cerberus.fon.sprintcorp.com!news From: Eric Williams Newsgroups: comp.lang.java Subject: Re: newbie: templates in Java ? Date: Tue, 05 Mar 1996 08:13:16 -0600 Organization: Sprint Message-ID: <313C4BFC.57AE@ksopk.sprint.com> NNTP-Posting-Host: shire.fon.sprintcorp.com Dr. Richard Botting wrote: > > >Eric Williams wrote: > > 2. Parameter type variables within the class may be treated as if they > > were of type Object... nothing further should be assumed about the > > API supported by the parameter type. > > I rather like being able to write down my > assumptions and have the compiler check them for me, > when this is possible... like in one or two other > languages. I agree. The compiler and JVM are not there yet. In the interim, if you need this kind of stuff, you can do it dynamically. > I was thinking about this before I read this thread... > I wanted to write a generic "SortableArray" class > where each array knows how to sort themselves - whatever > class of object that they contained. Different classes > of objects would be sorted by different criteria. In C > this appears via a function argument of void pointers and is > quite uncheckable. > > I can see how to do 95% of what I want... except for > one thing. How can > I make sure that the objects being sorted had some > comparison operator defined -- prefereably at compile > time. How about implementing a Comparable interface: public interface Comparable { /** * @returns 0 if equal-to anObject * @returns <0 if less-than anObject * @returns >0 if greater-than anObject */ public int compare(Comparable anObject); }; Implement this interface in whatever classes must be sortable. This is a common type of operation used in many collection class libraries (RogueWave, etc.). Note that you will be responsible for handling situations where the actual classes being compared are incompatible. I was actually surprised that Object does not define a comparison method.... they defined hashCode(), but no compare(). I guess they didn't want to force another method on the whole class hierarchy. -eric From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!swrinde!news.uh.edu!usenet Sat Mar 9 09:57:01 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!unogate!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!swrinde!news.uh.edu!usenet From: Jeff M Younker Newsgroups: comp.lang.java Subject: Re: Java endian Date: Fri, 08 Mar 1996 14:45:42 -0600 Organization: University of Houston High Performance Computing Center Message-ID: <31409C76.6DD4@uh.edu> NNTP-Posting-Host: farabi.hpc.uh.edu Peter Dekkers wrote: > > markt@harlqn.co.uk (Mark Tillotson) wrote: > >Well, DataOutputStream and DataInputStream do not _expose_ any > >inbuilt endianness at all... They define their own order for > >reading/writing multi-byte values onto streams, but anyone can write > >such methods---Java itself has no endianness, because it has no > >pointer arithmetic or unsafe operations.. > > Humm, depends perhaps on your defenition of endianness. Perhaps > coincidental but java's byteorder of a int is the same as that of for Java's DataInput Streams and DataOutputStreams use XDR, the External Data Representation Standard for their definition of byte orders. If memory serves me correctly, this is documented in the Java Class Libs somewhere (possible in the source). XDR itself is specified in RFC1832. A copy can be found at: http://www.cis.ohio-state.edu/htbin/rfc/rfc1832.html. This is the same representation that Remote Procedure Calls (RPC) use for communication, and hence NFS and several other services. Note that XDR was invented to do data exchange in a completely processor independent manner. It also has the effect of completely hiding the underlaying endianess of the processor. I will lay money that a java interpreter on a big endian machine will use big endian internals, and that a java interpreter on a little endian machine will use little endian internals. This makes questions of "is java little or big endian" completely senseless. - Jeff Younker - jeff@uh.edu - These are my views, not UH's - From csus.edu!csulb.edu!newshub.csu.net!newsserver.sdsc.edu!news.cerf.net!mvb.saic.com!news.mathworks.com!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!ggr.co.uk!ussun2n.glaxo.com!concert!bigblue.oit.unc.edu!tipper.oit.unc.edu!ses Sat Mar 9 10:40:26 1996 Path: csus.edu!csulb.edu!newshub.csu.net!newsserver.sdsc.edu!news.cerf.net!mvb.saic.com!news.mathworks.com!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!ggr.co.uk!ussun2n.glaxo.com!concert!bigblue.oit.unc.edu!tipper.oit.unc.edu!ses From: ses@tipper.oit.unc.edu (Simon E Spero) Newsgroups: comp.lang.java Subject: Re: Method verification error...? HELP! Date: 4 Mar 1996 05:51:51 GMT Organization: University of North Carolina, Chapel Hill Message-ID: <4he0dn$1h8g@bigblue.oit.unc.edu> NNTP-Posting-Host: tipper.oit.unc.edu In article <31364551.1E6B@algonet.se>, Filip Gyllensvaan wrote: >OK, I've uploaded my html docs & images & sounds to my homepage- >location. When I try to read them with my browser I get a > >"Applet can't start: class Animator got a security violation: method >verification error" > >message. They work fine when I run them "local". There is a bug relating to synchronization that could be causing your problem. The problem is triggered by attempting to create a scynchronization block using an array as the monitor. The current work-around is 'don't do that' :-) There are very few time when you need to use this construct; most of the cases that aren't solved by declaring a method synchronized aren't really helped by this case either. Sun is working on the problem. Handy debugging hint: If you get hit with a verification error, run your code under java or java_g using the "-verify" flag. This will report any verification errors with the method in which they occur. Simon From csus.edu!csulb.edu!BellSouth!news.iag.net!news.math.psu.edu!news.cse.psu.edu!uwm.edu!math.ohio-state.edu!usc!howland.reston.ans.net!newsfeed.internetmci.com!iol!tank.news.pipex.net!pipex!usenet1.news.uk.psi.net!uknet!psinntp!psinntp!psinntp!pubxfer.news.psi.net!usenet Wed May 29 11:36:49 1996 Path: csus.edu!csulb.edu!BellSouth!news.iag.net!news.math.psu.edu!news.cse.psu.edu!uwm.edu!math.ohio-state.edu!usc!howland.reston.ans.net!newsfeed.internetmci.com!iol!tank.news.pipex.net!pipex!usenet1.news.uk.psi.net!uknet!psinntp!psinntp!psinntp!pubxfer.news.psi.net!usenet From: Dave Zimmerman Newsgroups: comp.lang.java Subject: Re: main in Packages Date: Tue, 21 May 1996 10:09:21 -0400 Organization: Widget Workshop, Inc. Cary, NC Message-ID: <31A1CE91.2A28@widget.com> NNTP-Posting-Host: 204.241.231.2 Frank Marx wrote: > > package test; > import... ; > public class Simple { > > public static void main (String argv[]) { > String.out.println("Test!!"); > } > } > > I can compile this file with Symantec Cafe without errors, but when I try to run the > console application the interpreter says "can't find class Simple". > Did you run Simple or test.Simple? The later is the actual name of your app. -- \ The _____ \ /\ /idget \ \/ \/ _______ David Zimmerman The Widget Workshop \ /\ /orkshop dzimm@widget.com 1143-I Executive Circle \/ \/ Inc. 919 481 3352 Cary NC 27511 -- -HELLO! I'm a .signature virus! Join in and copy me into yours! From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!howland.reston.ans.net!newsfeed.internetmci.com!iol!tank.news.pipex.net!pipex!usenet2.news.uk.psi.net!uknet!psinntp!psinntp!psinntp!news.NetVision.net.il!news Wed May 29 11:37:09 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!howland.reston.ans.net!newsfeed.internetmci.com!iol!tank.news.pipex.net!pipex!usenet2.news.uk.psi.net!uknet!psinntp!psinntp!psinntp!news.NetVision.net.il!news From: Arthur Zavalkovsky Newsgroups: comp.lang.java Subject: Re: main in Packages Date: Wed, 22 May 1996 16:17:29 +0300 Organization: Armon Message-ID: <31A313E9.501D@armon.co.il> NNTP-Posting-Host: 194.90.88.88 Frank Marx wrote: > > Hi !! > > Is it possible to have the method "main" in a package ?? > > Example: > ======== > > package test; > > import... ; > > public class Simple { > > public static void main (String argv[]) { > String.out.println("Test!!"); > } > } > > I can compile this file with Symantec Cafe without errors, but when I try to run the > console application the interpreter says "can't find class Simple". > > Frank Marx > > (PS: a directory frank exists) > > No, No , No... > somebody is confused here !! > (B. Gates) How do you try to run the application? Go to the ..\test directory and type: java Simple.class. It should work. Arthur Zavalkovsky From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!csulb.edu!BellSouth!news.cc.emory.edu!cssun.mathcs.emory.edu!swrinde!elroy.jpl.nasa.gov!decwrl!enews.sgi.com!news.uoregon.edu!newsfeed.orst.edu!news.uidaho.edu!kuoi.asui.uidaho.edu!kamikaze Fri May 31 07:32:42 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!csulb.edu!BellSouth!news.cc.emory.edu!cssun.mathcs.emory.edu!swrinde!elroy.jpl.nasa.gov!decwrl!enews.sgi.com!news.uoregon.edu!newsfeed.orst.edu!news.uidaho.edu!kuoi.asui.uidaho.edu!kamikaze From: kamikaze@kuoi.asui.uidaho.edu (Mark Hughes) Newsgroups: comp.lang.java Subject: Re: Getting a random number from 1 (or 0) to i Date: 20 May 1996 16:29:25 GMT Organization: the Satellite of Love Distribution: world Message-ID: <4nq6l5$lu3@newshound.csrv.uidaho.edu> NNTP-Posting-Host: kuoi.asui.uidaho.edu X-Anagrams: * Soft volatile eel * Evil Seattle fool * Elf toilet loaves * Feel it, slave tool! X-MiSTie-Number: 58849 X-Newsreader: trn v3.6 X-HTTP: //kuoi.asui.uidaho.edu/~kamikaze/ X-Geek: GCS C++++ ULH+ P++>++++ L E--- W+++ N+++ w--- o? K+++ O+++ M V-- PS+++ PE Y+ PGP t--@ 5+++ X+ R++>+++$ tv+ b+++ DI++ D+++ G++ e* h* d--- s++: a- r(*) y+ (GC3.1 ) X-Day: July 5, 1998 Aaron Denney spake: >Is there any method in JAVA for generating a number from 1 (or 0) to any >other number? I generated a random no. from 1 to 3 by using Math.random >as follows: I had the same problem, so I hacked up the following. Compile it and put it somewhere CLASSPATH will see it... It's a bit faster than (int)(Math.random()*n). /* Rand.java by Mark Hughes derived from Sedgewick's _Algorithms_ Use and distribute freely with this header intact. Initialization: import Rand; Methods: public void srand() public void srand(int n) public int rand(int n) Usage: Rand.srand() or Rand.srand(seed) seeds the random number generator. Rand.rand(n) returns an int from 0..n-1. */ import java.util.Date; public class Rand { private static long seed = 0; private static final long m = 2147483648L; // Don't touch this line unless you know what you're doing. private static final long b = 31415821L; public static void srand() { seed = new Date().getTime(); } public static void srand(int n) { seed = n; } public static int rand(int n) { seed = (seed * b + 1) % m; return (int)( seed % n ); } } -Mark Hughes "In headlines today, the dreaded killfile virus spread across the country adding aol.com to people's usenet kill files everywhere. The programmer of the virus still remains anonymous, but has been nominated several times for a Nobel peace prize." -Mark Atkinson From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!news.cps.udayton.edu!news.engr.udayton.edu!blackbird.afit.af.mil!zombie.ncsc.mil!news.mathworks.com!newsfeed.internetmci.com!news-feed.iguide.com!news.delphi.com!usenet Fri May 31 07:33:12 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!news.cps.udayton.edu!news.engr.udayton.edu!blackbird.afit.af.mil!zombie.ncsc.mil!news.mathworks.com!newsfeed.internetmci.com!news-feed.iguide.com!news.delphi.com!usenet From: Roedy Green Newsgroups: comp.lang.java Subject: Re: Getting a random number from 1 (or 0) to i Date: 24 May 1996 06:33:58 GMT Organization: Canadian Mind Products Message-ID: <4o3l8m$7b6@news2.delphi.com> NNTP-Posting-Host: bix.com X-Newsreader: Galahad 1.3 To get a random number between 0 .. n use util.Random to get a random positive or negative integer, then corral it into range with Math.abs(r) % n; The Rand.rand code example presumes unsigned arithmetic or a remainder which follows the sign of the divisor which Java does not directly support. Java's modulus follows the sign of the dividend. Roedy@bix.com contract programming -30- From csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!venus.sun.com!cs.utexas.edu!howland.reston.ans.net!newsfeed.internetmci.com!realtime.net!news Fri May 31 07:33:50 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!venus.sun.com!cs.utexas.edu!howland.reston.ans.net!newsfeed.internetmci.com!realtime.net!news From: bill@otherwise.com (Bill Tschumy) Newsgroups: comp.lang.java Subject: Re: Getting a random number from 1 (or 0) to i Date: Fri, 24 May 1996 13:25:37 GMT Organization: Otherwise -- Austin, TX Message-ID: <4o4dda$1c0i@news3.realtime.net> NNTP-Posting-Host: apm1-89.realtime.net X-RTcode: 6cd13e0f31ea6a9366a5b8c7 X-Newsreader: Forte Free Agent 1.0.82 Roedy Green wrote: >To get a random number between 0 .. n use util.Random to get a random >positive or negative integer, then corral it into range with > Math.abs(r) % n; >The Rand.rand code example presumes unsigned arithmetic or a remainder >which follows the sign of the divisor which Java does not directly support. >Java's modulus follows the sign of the dividend. >Roedy@bix.com contract programming >-30- I would be very careful about doing things like Math.abs(r) % n to a random sequence. People that have studied pseudo-random number generators say that that kind of remapping can result in a sequence that is no longer a good random sequence. I have been using the following algorithm to get a random int between low and high (inclusive). public class RandomExt extends java.util.Random { public int nextInt(int low, int high) { /** * Returns a random int x such that low <= x <= high. */ return (int)(low + (high + 1 - low) * nextFloat()); } } I think this has a better chance of giving a good random sequence. ----- Bill Tschumy Otherwise -- Austin, TX Creators of Artificial Life bill@otherwise.com From csus.edu!csulb.edu!BellSouth!news.iag.net!news.math.psu.edu!news.cac.psu.edu!howland.reston.ans.net!newsfeed.internetmci.com!in2.uu.net!world!mv!dhabolt.natural.com!user Fri May 31 07:47:52 1996 Newsgroups: comp.lang.java Path: csus.edu!csulb.edu!BellSouth!news.iag.net!news.math.psu.edu!news.cac.psu.edu!howland.reston.ans.net!newsfeed.internetmci.com!in2.uu.net!world!mv!dhabolt.natural.com!user From: dhabolt@natural.com (John Dhabolt) Subject: Re: BUTTON questions Message-ID: Organization: MV Communications, Inc. Date: Wed, 22 May 1996 14:22:43 GMT Followup-To: comp.lang.java X-Nntp-Posting-Host: dhabolt.natural.com In article <4nt771$51i@netnews.upenn.edu>, mikesu@blue.seas.upenn.edu (Mike Su) wrote: Mike, > I have two questions. The first is a button question. How do you put > graphics (i.e. a GIF file) on a button rather than putting text in a > UI so that when you click on it, you can go to an event. Check out the following URLs for some examples (with source code) of classes that create "Image Buttons". It would be nice if there were an image button class in the JDK. It seems like a fairly common thing to do. * http://www.cs.brown.edu/people/amd/java/ImageButton/ * http://www.algonet.se/~jannea/JanneButton/JanneButton.html * http://www.realtime.net/~elijah/jindex.html * http://www.windward1.com/java/PictBar/CPictBar.html If none of the above work quite the way that you would like you might also visit www.gamelan.com and search for other examples of this. > The second > question is, if I have a java-drawn picture (i.e. a box), how do I > map that area so handle an event when the user clicks in that area? > Any help posted or emailed to me would be greatly appreciated. Check out the Sun demo "ImageMap" that ships with the JDK. There is also an excellent example of this in David Flanagan's book "Java in a Nutshell" (page 95). If you don't have the book (or don't want to type the code) he has the code posted on the net at http://www.ora.com/catalog/books/javanut/examples/. Just look for example 4-7. You can even run the example from the web page to see what it does. -- John C. Dhabolt \_ \_ \_ dhabolt@natural.com Manager of Technical Support \_\_\_ \_ Natural Intelligence, Inc. \_ \__ \_ tel (617) 876-7680 x1213 http://www.roaster.com/ \_ \_ \_ fax (617) 492-7425 From jlovett@wiley.csusb.edu Fri May 31 09:02 PDT 1996 Message-Id: <2.2.32.19960531154757.0075c6c8@wiley.csusb.edu> Date: Fri, 31 May 1996 08:47:57 -0700 From: Joseph Lovett Subject: Black Java Dick, Thought you would be interested in this blurb from Digital Dispatch. It points to sites with hostile Java Apps. Yours, Joe _________________________________________________________________________ c|net Digital Dispatch The newsletter of c|net: the computer network Vol. 2, No. 22 May 30, 1996 more than 437,000 subscribers http://www.cnet.com/ http://www.shareware.com/ http://www.search.com/ Java's everywhere this week. And like any good story, the tale of Java has had its share of good and bad news. The first major Java conference, Sun's JavaOne in San Francisco, showed a fascinating future including a Java operating system: http://www.cnet.com/Content/News/Files/0,16,1425,00.html ...and interactive apps on the Web... http://www.cnet.com/Content/News/Files/0,16,1430,00.html But a chapter of black Java is being written, too. Reports of hostile Java applications are on the increase. These apps can do anything from blocking other Java code to crashing your browser. c|net's editor in chief Christopher Barr covers the phenomenon in his column this week: http://www.cnet.com/Content/Voices/Barr/052796/ Feel free to follow the links to actual hostile Java applications. But don't go running any of them...unless you're prepared for the consequences. From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!agate!news.ossi.com!netserv.com!news.mathworks.com!newsfeed.internetmci.com!in1.uu.net!professionals.com!news Sat Jun 1 10:34:04 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!agate!news.ossi.com!netserv.com!news.mathworks.com!newsfeed.internetmci.com!in1.uu.net!professionals.com!news From: Chuck McManis Newsgroups: comp.lang.java Subject: Re: Dreaded Threads! Date: Tue, 28 May 1996 11:49:16 -0700 Organization: Personal Account Message-ID: <31AB4AAC.5123@netcom.com> NNTP-Posting-Host: www.free-gate.com Barney Rubble wrote: > The problem is, Timer is starting, getting suspended, and then > AThread starts, but the run() part of AThread keeps going until > it finishes, without being interrupted by Timer waking up. Threads with the same priority don't round robin on all platforms (most notably Linux). You should change the priority of one of the threads. Consider in the run() method of AThread doing this: (Thread.currentThread()).setPriority(Thread.MIN_PRIORITY); -- Chuck McManis http://www.professionals.com/~cmcmanis Director System Software, FreeGate Corp. cmcmanis@netcom.com All opinions in the non-included text above are those of the author and not of his employer or avocado plant. From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!howland.reston.ans.net!nntp.coast.net!news2.acs.oakland.edu!jobone!fiesta.srl.ford.com!eccdb1.pms.ford.com!usenet Sat Jun 1 10:36:22 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!usc!howland.reston.ans.net!nntp.coast.net!news2.acs.oakland.edu!jobone!fiesta.srl.ford.com!eccdb1.pms.ford.com!usenet From: Terry Bone Newsgroups: comp.lang.java Subject: Re: strings to integers in java Date: Thu, 23 May 1996 09:15:40 -0400 Organization: Ford Motor Credit Message-ID: <31A464FC.1B05@fc.ford.com> Reply-To: t_bone@earthlink.net NNTP-Posting-Host: 19.59.166.53 nic r wrote: > > What about converting a string to a float or a double??? From "The Java Programming Language" by Arnold and Gosling... Type To String From String ------------- -------------------------------- -------------------- boolean String.valueOf(boolean) new Boolean(String).booleanValue() int String.valueOf(int) Integer.ParseInt(String, int base) long String.valueOf(long) Long.ParseLong(String, int base) float String.valueOf(float) new Float(String).floatValue() double String.valueOf(double) new Double(String).doubleValue() -- ............................................................. . Terry Bone . . Ford Motor Credit - Technical Specialist . . tbone2@fc.ford.com . . t_bone@earthlink.net . . Explore the Java Hut: http://www.earthlink.net/~t_bone . ............................................................. From csus.edu!newsfeeder.sdsu.edu!news.iag.net!news.math.psu.edu!news.cac.psu.edu!howland.reston.ans.net!EU.net!sun4nl!fwi.uva.nl!not-for-mail Sun Jun 2 07:06:01 1996 Path: csus.edu!newsfeeder.sdsu.edu!news.iag.net!news.math.psu.edu!news.cac.psu.edu!howland.reston.ans.net!EU.net!sun4nl!fwi.uva.nl!not-for-mail From: delft@fwi.uva.nl (Andre van Delft) Newsgroups: comp.lang.java Subject: OK: user-defined operators are here! (Was: Java++ anyone?) Date: 1 Jun 1996 21:43:03 +0200 Organization: Delftware Technology BV Distribution: world Message-ID: <4oq6g7$a6h@adam.fwi.uva.nl> NNTP-Posting-Host: adam.fwi.uva.nl OK: user-defined operators are here! We implemented support for user-defined operators in the preprocessor coming with the Scriptic Developer's Kit (SDK), available from www.delftware.com and www.delftware.nl. You can now define the meaning of: x .< y - translates into a method call at x x <. y - translates into a method call at y x .<. y - translates into a static method call The latter form may be useful if you want to do comparisons on possible null values. All operators, except for field access ('.') get such dotted versions. Priorities are equal to those of the undotted versions. It is all syntactic sugar; this avoids most troubles with operator overloading as known from C++. Programmers track the operator definitions as easily as method definitions. More information is on www.delftware.com/operator.html. We are waiting for the first nice classes with user-defined operators. Area suggestions: complex math, matrix math, dictionaries, ... Please send them in! The next version of the preprocessor (RSN) will also support user-defined index operators and call operators. Andre van Delft From csus.edu!csusac!charnel.ecst.csuchico.edu!xmission!imci2!news.internetMCI.com!newsfeed.internetmci.com!in1.uu.net!satisfied.apocalypse.org!news2.near.net!maceo.emedia.net!dti-nntp Sun Jun 2 07:11:28 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!xmission!imci2!news.internetMCI.com!newsfeed.internetmci.com!in1.uu.net!satisfied.apocalypse.org!news2.near.net!maceo.emedia.net!dti-nntp From: darose@emedia.net (Dave Rosenstrauch) Newsgroups: comp.lang.java Subject: Re: Array declaration Date: Mon, 27 May 1996 18:46:43 GMT Organization: Digital Telemedia Inc. Message-ID: <4ocsvl$f9c@maceo.emedia.net> Reply-To: darose@emedia.net NNTP-Posting-Host: darose.emedia.net X-Newsreader: Forte Free Agent 1.0.82 bernd@nekkar.cs.pdx.edu (bernd anderer) wrote: >Hi >I tried to do the following : >______________________________________________________________________________ >import java.applet.*; >public class LP1 extends Applet >{ > static int tbl[][] = new int[3][6]; > tbl[1][1] = 5; > public void init() > { > > } >} >___________________________________________________________________________ >The compiler gives me this error message : >LP1.java:6: ']' expected. > tbl[1][1] = 5; >(I changed static to default/privat/public and int to float ... it didn't >change the result) >If I move line 6 into a methode everything is ok : >__________________________________________________________________________ >import java.applet.*; >public class LP1 extends Applet >{ > public int tbl[][] = new int[3][6]; > public void init() > { > tbl[1][1] = 5; > } > >} >Did I do something wrong or is it just not possible to do something like >this ?? >Thanks >Bernd >psu05624@odin.cc.pdx.edu Yep. This is a no-no. > tbl[1][1] = 5; ... is an assignment statement, and java requires that all statements must be within a method. It won't let you put any statement in the variable declaration area, which is what you have been trying to do. So this wouldn't be valid either: > static int tbl; > tbl = 5; But this would: > static int tbl = 5; Assigning a value this way is allowed since it is part of the declaration of the variable. And so would this, for the same reason: > static int[] tbl = {97, 98, 99, 100}; If you move the assignment statement into the init() method you should be fine. Dave Rosenstrauch DAR Systems Inc. http://members.aol.com/darsystems/ From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!bunyip.cc.uq.oz.au!harbinger.cc.monash.edu.au!news.uwa.edu.au!disco.iinet.net.au!news.uoregon.edu!arclight.uoregon.edu!gatech!news.mathworks.com!newsgate.duke.edu!agate!hpg30a.csc.cuhk.hk!news.cuhk.edu.hk!hkusuc.hku.hk!news.cs.hku.hk!phoenix!clchau Sun Jun 2 07:20:53 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!bunyip.cc.uq.oz.au!harbinger.cc.monash.edu.au!news.uwa.edu.au!disco.iinet.net.au!news.uoregon.edu!arclight.uoregon.edu!gatech!news.mathworks.com!newsgate.duke.edu!agate!hpg30a.csc.cuhk.hk!news.cuhk.edu.hk!hkusuc.hku.hk!news.cs.hku.hk!phoenix!clchau From: clchau@cs.hku.hk (Lucky Michael) Newsgroups: comp.lang.java Subject: Re: L.E.D. Applet----- WHERE CAN I FIND IT???? Date: 24 May 1996 05:27:17 GMT Organization: Department of Computer Science, The University of Hong Kong Message-ID: <4o3hbl$b5f@ns.cs.hku.hk> NNTP-Posting-Host: phoenix.cs.hku.hk X-Newsreader: TIN [version 1.2 PL2] Lucky Michael (clchau@cs.hku.hk) wrote: : Greg Chandler (gchand@inow.com) wrote: : : Need it DESPERATELY!!! : You may find one here : : ftp://ftp.cs.hope.edu/public/java/LEDSign/LEDSignV25.tar.gz ^^^^^^ ^^ This one is really incorrect. Also, a newer version is available: ftp://ftp.cs.hope.edu/pub/java/LEDSign/LEDSignV27.tar.gz ----------------------------------------------------------------------------- | Michael C. L. Chau | Pager : 71128632 a/c 2980 | | Information Systems Year 1 | Mail : clchau@student.cs.hku.hk | | Computer Science Department | h9504369@hkusua.hku.hk | | The University of Hong Kong | URL : http://www.cs.hku.hk/~clchau/ | ----------------------------------------------------------------------------- From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!imci3!newsfeed.internetmci.com!in1.uu.net!news.mathworks.com!news.kei.com!nntp.coast.net!fu-berlin.de!golden-gate.owl.de!uni-paderborn.de!news.rwth-aachen.de!news Sun Jun 2 07:23:17 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!imci3!newsfeed.internetmci.com!in1.uu.net!news.mathworks.com!news.kei.com!nntp.coast.net!fu-berlin.de!golden-gate.owl.de!uni-paderborn.de!news.rwth-aachen.de!news From: Marcus Gruendler Newsgroups: comp.lang.java Subject: Re: JDK javadoc Date: Fri, 24 May 1996 13:07:36 +0200 Organization: RWTH -Aachen / Rechnerbetrieb Informatik Message-ID: <31A59878.225B@pool.informatik.rwth-aachen.de> NNTP-Posting-Host: marlowe.informatik.rwth-aachen.de Anthony Ciprick wrote: > > Has anyone gotten javadoc to work properly? It seems to generate the > individual pages for each class ok, but as far as getting a package to > be linked together nicely, I can't figure it out. > > Thanks, > Anthony Ciprick > CIBC Hi Anthony I JUST read your request and realized, that I had the same problems in making HTML-docs with packages. What you should do: Example: package example.number1; . . . package example.number2; . . . Assuming you have these two packages in the correct directory structure that is /example/number1/*.java and /example/number2/*.java Now you change directory to / Call: javadoc example This should do it (at least it did in my environment ;-) ) Remember the CLASSPATH environment variable. Bye bye, Marcus From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.unimelb.EDU.AU!cpsg.com.au!usenet Sun Jun 2 07:23:45 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!munnari.OZ.AU!news.unimelb.EDU.AU!cpsg.com.au!usenet From: azris@cpgen.cpsg.com.au (Simon Azriel) Newsgroups: comp.lang.java Subject: Re: JDK javadoc Date: Sun, 26 May 1996 22:44:04 GMT Organization: Computer Power Group - Telemedia Software Labs Message-ID: <4oaqcs$3ah@ginah.cpsg.com.au> NNTP-Posting-Host: pc899.cpgen.cpg.com.au X-Newsreader: Forte Free Agent 1.0.82 Anthony Ciprick wrote: >Has anyone gotten javadoc to work properly? It seems to generate the >individual pages for each class ok, but as far as getting a package to >be linked together nicely, I can't figure it out. >Thanks, >Anthony Ciprick >CIBC To link from one class to another you need an @see in you class comment eg. /** * a class that does something usefull * @see AnotherClass * */ This will give you a link to the other class. The @see can be used before classes, methods or variables. Simon Azriel Computer Power Group - Telemedia Software Labs Melbourne VIC, Australia. azris@cpgen.cpg.com.au ThisMessage extends MyOpinion throws ComputerPowerException From csus.edu!csusac!charnel.ecst.csuchico.edu!xmission!newsfeed.kdcol.net!news.iag.net!news.math.psu.edu!news.cac.psu.edu!howland.reston.ans.net!EU.net!Austria.EU.net!01-newsfeed.univie.ac.at!uw.edu.pl!cyfronet!usenet Sun Jun 2 07:38:29 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!xmission!newsfeed.kdcol.net!news.iag.net!news.math.psu.edu!news.cac.psu.edu!howland.reston.ans.net!EU.net!Austria.EU.net!01-newsfeed.univie.ac.at!uw.edu.pl!cyfronet!usenet From: artur@flugor.if.uj.edu.pl (Artur Pioro) Newsgroups: comp.lang.java Subject: Re: Timeslicing with Java on Solaris 2.5 Date: 27 May 1996 20:13:37 +0200 Organization: Jagiellonian University Message-ID: <53u3x2rnla.fsf@flugor.if.uj.edu.pl> <4o4non$nj5@lard.ftp.com> NNTP-Posting-Host: flugor-atm.if.uj.edu.pl In-reply-to: jmillar@ftp.com's message of Fri, 24 May 1996 16:12:47 GMT X-Newsreader: Gnus v5.0.15 >>>>> "Joseph"==Joseph Millar writes: Joseph> Hopefully Sun will see the light and use native threads in a Joseph> future release (maybe the much talked about 1.1?). As that topic is already touched - what difference does it make if timeslicing is made by JVM or not? Is this worse approach to implement it yourself? Just by creating some high - priority thread (the daemon one) consisting of an infinite loop in which it does nothing but sleeps for short periods of time? As long as you keep in mind that it must be the highest priority thread in your app and don't mind those few additional cpu cycles it should work, shouldn't it? And according to Thread specification it should work with *any* JVM. I just wonder why creators of Java Tutorial didn't mention such simple approach when while talking about timesliceing. Or am I missing something important? -- Artur From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!newsfeed.internetmci.com!news.mathworks.com!newsgate.duke.edu!agate!boulder!boussinesq.Colorado.EDU!sherod Sun Jun 2 07:46:09 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!newsfeed.internetmci.com!news.mathworks.com!newsgate.duke.edu!agate!boulder!boussinesq.Colorado.EDU!sherod From: sherod@boussinesq.Colorado.EDU (Scott Herod) Newsgroups: comp.lang.java Subject: Re: Tabbing through Components Date: 24 May 1996 18:43:04 GMT Organization: University of Colorado at Boulder Distribution: world Message-ID: <4o4vvo$dd0@lace.colorado.edu> NNTP-Posting-Host: boussinesq.colorado.edu I have an example where I allow tabbing through text fields. The text fields are all part of a Panel and are set up using a grdbag layout. The code to do the tabbing is ========================== public boolean handleEvent(Event e) { if (e.target instanceof TextField) { if (e.key == 9 && e.id == Event.KEY_PRESS) { if (e.target == eqn1) xmin.requestFocus(); if (e.target == xmin) xmax.requestFocus(); if (e.target == xmax) eqn1.requestFocus(); return true; }; }; return false; } ============================= Here, xmin, xmax and eqn1 are the names of the textfields. The applet is located at http://amath-www.colorado.edu/appm/faculty/sherod/classes/Phasor/graph.html Scott In article <31A5C595.55C5@city.net>, Rowland Smith writes: |> I am trying to find a good way to handle using the tab key to move from |> component to component (TextField, Choice, etc.) in a frame. I can't |> find any references to doing this in any Java books, so I guess you have |> to roll your own. |> |> I want to do it without having to subclass any of the standard GUI |> components. |> |> Does anyone know how to tell if a particular component has the input |> focus? |> |> I want to be able to just trap the tab key at the container level (which |> I have tested, and it works), and then ask the container which component |> has the input focus. Then I'll just find the next component and |> call 'requestFocus()' on it. |> |> This idea should work, but only if you can tell which component has the |> focus. |> |> Thanks, |> |> MonkyBoy From csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!imci3!newsfeed.internetmci.com!info.ucla.edu!agate!sunsite.doc.ic.ac.uk!sunews!suma3!ssu94102 Wed Jun 5 11:32:53 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!newshub.csu.net!imci3!newsfeed.internetmci.com!info.ucla.edu!agate!sunsite.doc.ic.ac.uk!sunews!suma3!ssu94102 From: Gerard Davison Newsgroups: comp.lang.java Subject: Re: Profiling an Applet... Date: Tue, 28 May 1996 10:32:45 +0100 Organization: University of Reading, U.K. Message-ID: NNTP-Posting-Host: suma3-e2.reading.ac.uk In-Reply-To: <4occkd$krg@epervier.CC.UMontreal.CA> On 27 May 1996, TRUSSART Vincent wrote: > > Is there a way to profile an APPLET? > I know how to do it for an application, > (java -prof "classname"), but appletviewer -prof > doesn't work... :( Yeah you have to do this instead: java -prof sun.applet.AppletViewer wibble.html you can work this out be looking at the appletviewer batch file Regards Gerard > > Any help would be appreciated... > > -- > Vincent Trussart > trussarv@jsp.umontreal.ca > Universite de Montreal > Quebec > > --- "Any sufficiently advanced technology is indistinguishable from magic." -- Arthur C. Clarke (GMDavison@iee.org) From csus.edu!csusac!zimmer.CSUFresno.EDU!waldorf.csc.calpoly.edu!decwrl!enews.sgi.com!news.mathworks.com!newsfeed.internetmci.com!netnews.nwnet.net!symiserver2.symantec.com!TARDIS Tue Jun 11 11:20:50 1996 Path: csus.edu!csusac!zimmer.CSUFresno.EDU!waldorf.csc.calpoly.edu!decwrl!enews.sgi.com!news.mathworks.com!newsfeed.internetmci.com!netnews.nwnet.net!symiserver2.symantec.com!TARDIS From: aidsinga@symantec.com (Andrew Idsinga) Newsgroups: comp.lang.java Subject: Re: Go to a web page from a Java applet Date: Fri, 31 May 96 17:58:34 GMT Organization: Symantec Corp. Message-ID: <4onck6$dkm@symiserver2.symantec.com> NNTP-Posting-Host: 155.64.182.122 X-Newsreader: News Xpress 2.0 Beta #0 In article , MLC@IBERIA.CCA.ROCKWELL.COM wrote: >I'd like to be able to click on a Java applet area and go to a web >page defined by that applet. The applet itself would determine which >page to get. Michael, A simplistic example would be to have a TextField object on a form with a "GO" button. The button's method could then create an URL object and use the showDocument() method to get there. Is this along the lines of what you were thinking? Hope this helps. Andrew Idsinga Symantec Product Support Win Devtools (C++/Cafe) From csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!nntp.msstate.edu!cssun.mathcs.emory.edu!gatech!gt-news!prism!prism!not-for-mail Tue Jun 11 11:32:56 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!olivea!nntp.msstate.edu!cssun.mathcs.emory.edu!gatech!gt-news!prism!prism!not-for-mail From: gt2071d@prism.gatech.edu (Kevin N. Leeds) Newsgroups: comp.lang.java Subject: Color map - experimental evidence - Sun, XWindows, appletviewer. Date: 30 May 1996 16:47:36 -0400 Organization: Georgia Institute of Technology, Atlanta Georgia Message-ID: <4ol1h8$8du@acmex.gatech.edu> NNTP-Posting-Host: acmex-prism.gatech.edu Summary: not very many colors can be depended on. This is in response to several questions which I found on this group last night when I came here for answers. The problem is to make an applet get specified R,G,B colors. The situation seems to be grim: by using setColor the applet can request an RGB color, but what it actually gets is not guaranteed. It is even grimmer because getColor does not tell you what color is actually being used; it just tells you what color you tried to get with setColor. This grimness was discovered while running ColorPicker applets from Gamelon. The labels weren't corresponding well with the colors I saw. Supporting evidence: trying to shade a 3-D object with various intensities of cyan (let blueness = greenness and let redness vary). I got some undesired shades of green and blue and grey when doing that. By experimenting I seem to find that appletviewer seizes 32 colors from my XWindows server. These are the only ones that can be counted on. I figured this out by bringing up an appletviewer and then trying to run xearth -ncolors N for different values of N starting at 512 and decreasing. 256 was too many so I decreased from there by 8 until it finally got enough colors to run when N was 224. Once xearth was running with -ncolors 224 I brought up a color picker applet and noted what colors the colorpicker actually got. The only hue that has a decent gradation of intensities to shade with is gray. Therefore, I will use that to do the shading and show the 3-D object. This is a worse-case assumption - another way to do this is to let the user choose a hue, then let the applet try to find a good gradation of intensities and show it to the user. Comments? I guess that Netscape might work the same. I don't know how all this would work on other platforms besides a Sun with XWindows. (I have Solaris here, which I suspect is irrelevant.) -- Kevin Nathaniel Leeds Atlanta, Georgia, USA From csus.edu!csusac!charnel.ecst.csuchico.edu!waldorf.csc.calpoly.edu!decwrl!enews.sgi.com!lll-winken.llnl.gov!fnnews.fnal.gov!unixhub!news.Stanford.EDU!morrow.stanford.edu!usenet Tue Jun 11 12:00:40 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!waldorf.csc.calpoly.edu!decwrl!enews.sgi.com!lll-winken.llnl.gov!fnnews.fnal.gov!unixhub!news.Stanford.EDU!morrow.stanford.edu!usenet From: Michael Klein Newsgroups: comp.lang.java Subject: Re: Returning values from Dialog subclass. Date: Fri, 31 May 1996 07:59:44 -0700 Organization: DataTools, Inc. Message-ID: <31AF0960.46FA@datatools.com> NNTP-Posting-Host: datatools.com CC: klein This is a multi-part message in MIME format. --------------2DCB48B32A21 Ray Hollett wrote: > > Could someone please explain how to return a value from a Dialog subclass. > The problem I have is that I wish to use a subclass of Dialog to set the > current font. I also wish to reuse this Dialog in several applications. I > make the Dialog modal to capture all the events for that application (but > unlike FileDialog this is not blocking on the thread). > > The scenario is: > 1. The subclass constructor is called and shows the Choice components. > 2. The font is selected and the Ok button is hit. > 3. The subclass event handler is passed the Ok button event and works out > the required font. > > Now is where I am stuck. How do I get the selected font back to the parent > frame for this Dialog. > > I have tried various tricks to get the value back but to no avail. > Does anyone have a simple example - or am I doing something fundamentally > wrong. > > Thanks in anticipation. > Ray Hollett. Try the attached code. This code assumes that modal dialogs block, which they do for JDK 1.0.2 on Solaris, but I've heard of problems in WinNT/95, although I have not verified this. Michael Klein --------------2DCB48B32A21 Content-Disposition: inline; filename="DialogExample.java" import java.awt.*; public class DialogExample extends Frame implements DialogCallback { public static void main(String args[]) { Frame f = new DialogExample(); f.pack(); f.resize(600, 400); f.show(); } public DialogExample() { setTitle("DialogExample"); Panel p = new Panel(); p.add(new Button("Dialog")); p.add(new Button("Quit")); add("North", p); textArea = new TextArea(); add("Center", textArea); } public boolean action(Event event, Object arg) { if (arg.equals("Dialog")) { MyDialog dialog = new MyDialog(this); dialog.show(); textArea.appendText("dialog response = " + response + "\n"); } else if (arg.equals("Quit")) { System.exit(0); } else return super.action(event, arg); return true; } public boolean handleEvent(Event event) { if (event.id == Event.WINDOW_DESTROY && event.target == this) System.exit(0); return super.handleEvent(event); } public void setDialogValue(String dialogValue) { response = dialogValue; } TextArea textArea; String response; } class MyDialog extends Dialog { public MyDialog(Frame parent) { super(parent, "DialogExample", true); Panel p1 = new Panel(); p1.add(new Label("type something here")); add("North", p1); Panel p2 = new Panel(); text = new TextField(20); p2.add(text); add("Center", p2); Panel p3 = new Panel(); p3.add (new Button("Ok")); add ("South", p3); resize(220, 150); frame = (DialogCallback)parent; } public boolean action(Event event, Object arg) { if (arg.equals("Ok")) { frame.setDialogValue(text.getText()); dispose(); return true; } return false; } private DialogCallback frame; private TextField text; } interface DialogCallback { void setDialogValue(String value); } --------------2DCB48B32A21-- From csus.edu!csulb.edu!BellSouth!gatech!news.cse.psu.edu!uwm.edu!newsfeed.internetmci.com!in1.uu.net!satisfied.apocalypse.org!news2.near.net!lard.ftp.com!news-control Wed Jun 19 14:43:19 1996 Path: csus.edu!csulb.edu!BellSouth!gatech!news.cse.psu.edu!uwm.edu!newsfeed.internetmci.com!in1.uu.net!satisfied.apocalypse.org!news2.near.net!lard.ftp.com!news-control From: jmillar@ftp.com (Joseph Millar) Newsgroups: comp.lang.java.programmer Subject: Re: outputstream: append? Date: Wed, 19 Jun 1996 18:11:57 GMT Organization: FTP Software, Inc. Message-ID: <4q9gj3$gd3@lard.ftp.com> NNTP-Posting-Host: jmillar-2.ftp.com X-Newsreader: Forte Free Agent 1.0.82 jwe@rahul.net (John W. Earl) wrote: > I downloaded JDK 1.02 (I think that's it) and have been trying > to write programs in Java but I keep running into a big barrier. > How do you open a file in append mode? Every time I open a > FileOutputStream, I end up blanking the file. Use the RandomAccessFile class and seek to the end first. I like to use the PrintStream class for output, so I do: RandomAccessFile ra = new RandomAccessFile ("xxx", "rw"); ra.seek (ra.length()); PrintStream ps = new PrintStream (new FileOutputStream (ra.getFD())); ps.println ("This line is added to the bottom of the file."); Hope this helps. --Joe ___________________________________________________________________ Joseph A. Millar FTP Software, Inc. Software Engineer Ph: (508) 684-6461 100 Brickstone Square jmillar@ftp.com Fax:(508) 684-6992 Andover, MA 01810 http://www.ftp.com USA From csus.edu!csulb.edu!BellSouth!gatech!usenet.eel.ufl.edu!spool.mu.edu!munnari.OZ.AU!news.mel.connect.com.au!harbinger.cc.monash.edu.au!nntp.coast.net!news-res.gsl.net!news.gsl.net!news.mathworks.com!newsfeed.internetmci.com!realtime.net!news Mon Jun 24 06:09:48 1996 Path: csus.edu!csulb.edu!BellSouth!gatech!usenet.eel.ufl.edu!spool.mu.edu!munnari.OZ.AU!news.mel.connect.com.au!harbinger.cc.monash.edu.au!nntp.coast.net!news-res.gsl.net!news.gsl.net!news.mathworks.com!newsfeed.internetmci.com!realtime.net!news From: bill@otherwise.com (Bill Tschumy) Newsgroups: comp.lang.java,comp.lang.misc Subject: Re: Is this a compiler bug? Date: Fri, 21 Jun 1996 14:25:41 GMT Organization: Otherwise -- Austin, TX Message-ID: <4qebc4$chq@news3.realtime.net> NNTP-Posting-Host: apm3-139.realtime.net X-RTcode: e1417c2e31c463daf5cab028 X-Newsreader: Forte Agent .99e/32.227 Xref: csus.edu comp.lang.java:62878 comp.lang.misc:20512 Joel Dubbels wrote: >Based on the Java Language Specification dated >October 1995, we realize a discrepancy between >the Language Spec and the compiler implementation. >Consider the following example. >class foo { > private protected int i; > void SetFoo(foo f){f.i = 1;} // comiles ok > void SetBar(bar b){b.i = 1;} // compiles ok >} >class bar extends foo { > void ModFoo(foo f){f.i = 1;} // compile error > void ModBar(bar b){b.i = 1;} // compiles ok >} >According to the Spec, combining (the) two >modifiers (private protected) is a compile time >error. >Our compiler does not report that error. >Instead the compiler behaves as indicated above. >Our question now is: is there another (from a later >date) language specification available or >is this actually a bug in the current release of >the compiler? It is a "bug". Apparently they were considering allowing the private protected combo for a while, but they have decided to pull it. It will not be supported in future compilers. ----- Bill Tschumy Otherwise -- Austin, TX Creators of Artificial Life bill@otherwise.com From csus.edu!csulb.edu!info.ucla.edu!nnrp.info.ucla.edu!agate!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!news.ox.ac.uk!sable.ox.ac.uk!lady0065 Mon Jun 24 06:17:59 1996 Path: csus.edu!csulb.edu!info.ucla.edu!nnrp.info.ucla.edu!agate!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!news.ox.ac.uk!sable.ox.ac.uk!lady0065 From: lady0065@sable.ox.ac.uk (David Hopwood) Newsgroups: comp.lang.java.security Subject: Re: The 64 Thousand Dollar Question Date: 20 Jun 1996 01:54:41 GMT Organization: Oxford University, England Message-ID: <4qab11$9v4@news.ox.ac.uk> NNTP-Posting-Host: sable.ox.ac.uk In article <4q9nm2$sop@alpha.sky.net>, wrote: >Danno Ferrin (drferrin@mines.edu) wrote: >: To date there are three (or more?) distinct attacks on Java, Domain Name >: Spoofing, the Hopwood ClassLoader Atttack, and the Princton ClassLoader >: Attack that could have real potential security problems with the system. I count a minimum of 10: Two hosts attack May ClassLoader attack acl.read/acl.write bug LiveConnect ClassLoader attack Unregistered hostname bug March ClassLoader attack Absolute pathname bug DNS spoofing 'protected' modifier clone() on any object of which the top 3 are not fixed in one of JDK 1.0.2 or NS 2.02. I'm also considering another two attacks (which may or may not work out). See http://ferret.lmh.ox.ac.uk/~david/java/bugs/ >: Not to mention numerous hostile applets. >: >: Now for the $64,000 question, are there any non-trivial exploitations of >: these security holes in current use? By non-trivial I mean actual >: damaging stuff that is more than a proof-of-concept attack, like the proof >: of the Hopwood ClassLoader attack on SGIs or the hostile apps from >: Georgia Tech. Not as far as I know. OTOH some of them can be made virtually untraceable - for example you could just attack a single machine and then remove the applet. >While I don't have an answer to that, it should not be very hard to >1. write a program to determine whether a bytecode sequence contains a > known attack. It's not quite that easy - in some cases an attack is indistinguishable from an accidental bug, so you would get a few false positives. >2. write a program to follow web links around, looking for java applets > described in (1) > >3. take a system which is properly backed up, and has appropriate md5s > on read-only media, and take netscape 2.00 to the URLs found by program > 2. Once you've done this, reboot off floppy or cd, and compare the md5s. Not really practical. You would be more likely to find known attacks by adding code to the fixed version of the browser to try to detect them (possible for some attacks, not for others). David Hopwood david.hopwood@lmh.ox.ac.uk http://ferret.lmh.ox.ac.uk/~david/ From csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cs.utexas.edu!uwm.edu!homer.alpha.net!news.ultranet.com!usenet.eel.ufl.edu!warwick!lyra.csx.cam.ac.uk!news Sat Jun 29 07:48:47 1996 Path: csus.edu!csulb.edu!drivel.ics.uci.edu!news.service.uci.edu!ihnp4.ucsd.edu!swrinde!cs.utexas.edu!uwm.edu!homer.alpha.net!news.ultranet.com!usenet.eel.ufl.edu!warwick!lyra.csx.cam.ac.uk!news From: Quentin Stafford-Fraser Newsgroups: comp.lang.java.programmer Subject: Re: Problem with javah, please HELP ! Date: Tue, 25 Jun 1996 10:34:56 +0100 Organization: Olivetti Research Ltd Message-ID: <31CFB2C0.34FA@cam-orl.co.uk> NNTP-Posting-Host: rapier.cam-orl.co.uk Andrew Idsinga wrote: > What is happening is javah is messing the first entry in your > CLASSPATH environment. Usually this is equal to '.;' --which > represents the current directory. ... > Work around: > Create a c:\temp directory (or whatever depending on platform) > and that add 'c:\temp;' to the beggining of the CLASSPATH variable. Wonderful, thanks - this bug had bitten me too. 2 minor points: * An easier solution is just to put '.' as the first TWO entries on the CLASSPATH. * Of course, if you're using the javah that comes with Cafe, you need to make these changes in sc.ini, not just to the environment variable. Quentin -- --------------------------------------------------------------------- Quentin Stafford-Fraser http://www.cam-orl.co.uk/~qsf Research Scientist Olivetti Research Ltd From csus.edu!csulb.edu!BellSouth!gatech!news.mathworks.com!news.PBI.net!samba.rahul.net!rahul.net!a2i!news.vbc.net!news.mira.net.au!news.mel.connect.com.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!news.cs.su.oz.au!not-for-mail Fri Jul 12 11:38:42 1996 Path: csus.edu!csulb.edu!BellSouth!gatech!news.mathworks.com!news.PBI.net!samba.rahul.net!rahul.net!a2i!news.vbc.net!news.mira.net.au!news.mel.connect.com.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!news.cs.su.oz.au!not-for-mail From: gary@cs.su.oz.au (Gary Capell) Newsgroups: comp.object,comp.lang.java.programmer Subject: Re: Design by Contract and Java Date: 12 Jul 1996 15:14:58 +1000 Organization: Basser Dept of Computer Science, University of Sydney, Australia Message-ID: <4s4n0i$ots@staff.cs.su.oz.au> NNTP-Posting-Host: staff.cs.su.oz.au X-Newsreader: NN version 6.5.0 #1 (NOV) Xref: csus.edu comp.object:50676 comp.lang.java.programmer:1214 j2lynn@undergrad.math.uwaterloo.ca (James F'jord Lynn) writes: [talking about trying to get the effects of or (even better) Eiffel's assertion constructs under java] > I agree, but you are the one who brought it around in a circle. Reread > Gary's statement. Please don't. I just did and saw that I was being silly. > If the test is inlined under an "if (false)" it will be removed. Inlining > is like a preprocessor. It will take Here's where I think you (and I) are wrong: I thought given class Assert { ... assert(Bool cond) { if (false) { if(!cond) throw ... } } } and class Foo { (1) ... Assert.assert(expensiveFunction()) the inlining would replace (1) with if(false) { if (!expensiveFunction()) throw ... } inside Foo, letting the compiler avoid expensiveFunction() Wrong-o. More likely the replacement will look like { tmp = expensiveFunction() if(false) {if (!tmp) throw ...} } and the compiler won't be able to avoid expensiveFunction() because it can't be certain there are no side-effects. *sigh* looks like the support for assertions still needs to be built in to the language. I don't see why a few other design-by-contract constructs can't be bolted on to java sometime. e.g. class Foo { [ // instance invariants, // checked before and after every method call bexpr1(); // boolean expression, must eval to true bexpr2(); ] public static void function() [ // preconditions bexpr3(); bexpr4(); ] { stmnt; stmnt; } [ // postconditions bexpr5(); bexpr6(); ] } I'm guessing these few additions to the syntax shouldn't break existing code, and would certainly make me a lot happier, particularly if invariants and preconditions are inherited properly. > However, I am not advocating the use of inlining in a Java compiler. If > it did have it, I would certainly hope there would be an off switch to > the inlining. Since Java is a dynamically linked language, I can > theoretically make a change to the implementation to an object and, as > long as it fullfills its contracts, drop it in place of an older version. > If there is inlining, then this model is destroyed since I must also > recompile, redistributed, and reinstall all of the objects that ever used > my object (and possibily all those that used them too). Not really great > for the whole instant update across a switch thing. That's why the compiler only inlines functions it is certain can't be overridden or dynamically dispatched, so the problems you mention above don't arise. I guess declaring a function to be final is like an "on" switch to the inlining. -- http://www.cs.su.oz.au/~gary/ From csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!usenet.eel.ufl.edu!newsfeed.internetmci.com!howland.reston.ans.net!newsjunkie.ans.net!newsfeeds.ans.net!jpmorgan.com!usenet Fri Jul 12 11:39:50 1996 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!usenet.eel.ufl.edu!newsfeed.internetmci.com!howland.reston.ans.net!newsjunkie.ans.net!newsfeeds.ans.net!jpmorgan.com!usenet From: bytor@virgin.ny.jpmorgan.com (Ross Huitt) Newsgroups: comp.object,comp.lang.java.advocacy Subject: Assertions (was Re: Design by Contract and Java) Date: 12 Jul 1996 15:01:37 GMT Organization: JPMorgan Message-ID: <31E23387.52EA@earthlink.net> <4rv08k$3f0@staff.cs.su.oz.au> <4s15di$cq2@shellx.best.com> NNTP-Posting-Host: virgin.ny.jpmorgan.com In-reply-to: davisre@best.com's message of 10 Jul 1996 13:56:18 -0700 Xref: csus.edu comp.object:50697 comp.lang.java.advocacy:385 class Assert { public static final int fEnabled = false; public static void assert(boolean test) { if (fEnabled && !test) throw new AssertionException (); } } usage: Assert.assert(Assert.fEnabled && this.timeConsumingOperation()); This will not execute 'this.timeConsumingOperation()' if fEnabled is false because '&&' short-circuits if the first expression is false. The code for the call will still be generated, it just won't be executed. -bytor In article <4s15di$cq2@shellx.best.com> davisre@best.com (Robert Davis) writes: [snip] > > It isn't wrapped inside the if(false). This discussion is going > around in circles. If I have code in MyClass that does this: > > Assert.assert(this.timeConsumingOperation()); > > and if the Assert class looks something like this: > > static final int assertionsEnabled = false; > > public static void assert (boolean test) { > if (assertionsEnabled) { > if (!test) { > throw new AssertionException (); > } > } > } > > will timeConsumingOperation() still be performed? With Sun's 1.0.2 > javac, it will. Eliminating the stuff within the 'if' is easy -- but > getting rid of the part that does all the work of setting 'test' to > true or false is the subject of the debate. > > > Rob > -- > Rob Davis Work: davis@lighthouse.com Home: davis@coaster.com From owner-sigcse.members@ACM.ORG Wed Jan 15 21:52 PST 1997 Message-Id: <199701160543.AAA28856@mail.acm.org> Date: Thu, 16 Jan 1997 16:34:03 EST-10 Reply-To: Dale Shaffer From: Dale Shaffer Organization: Monash Uni. School of Computing&IT Subject: Summary of CS1 Java books I have received information on the following Java books that are intended for use in CS1. All are from Addison Wesley! "Java Gently" by Judith Bishop (Univ of Petoria). Bound book due in April. "Java Software Solutions" by Loftis and Lewis. Preliminary edition now available. "On to Java" by Winston. Available now. Lynn Andrea Stein of MIT's AI Lab is working on a Java course and book. Information is at: http://www.ai.mit.edu/projects/cs101 In terms of Data Structures, "Data Structures in Java" by S. Venugopal (McGraw-Hill) will be available soon. All of what I have seen (not necessarily including the above) does applications first. I would be particularly interested in hearing from someone teaching applets first. Dale -------- Dale Shaffer, Ph.D. --------- dShaffer@Lander.Edu -------- Professor of Computer Science, Lander University, Greenwood, SC USA academic exchange 7-96 to 7-97: Monash University - Gippsland, Churchill, Victoria, 3842 Australia Web page-> http://www-gscit.fcit.monash.edu.au/~dales/dale.html From csus.edu!csusac!charnel.ecst.csuchico.edu!waldorf.csc.calpoly.edu!HSNX.wco.com!news.wco.com!news-out.internetmci.com!newsfeed.internetmci.com!rill.news.pipex.net!pipex!uknet!usenet1.news.uk.psi.net!uknet!nnrp1.news.uk.psi.net!uknet!not-for-mail Thu Mar 6 06:40:36 1997 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!waldorf.csc.calpoly.edu!HSNX.wco.com!news.wco.com!news-out.internetmci.com!newsfeed.internetmci.com!rill.news.pipex.net!pipex!uknet!usenet1.news.uk.psi.net!uknet!nnrp1.news.uk.psi.net!uknet!not-for-mail From: Giles Thomas Newsgroups: comp.lang.java.programmer Subject: Re: Help! Date: Wed, 26 Feb 1997 16:25:49 +0000 Organization: Imperial Software Technology Ltd. Message-ID: <3314640D.2FA4@ist.co.uk> NNTP-Posting-Host: isbalham.ist.co.uk Kate Collins wrote: > > Hi - > > I'm a java newbie having problems with mouse events. Is it possible > to use mouseEnter with one image with different areas in it as > "hotspots?" Specify the rectangle's dimensions or something? Or > do I have to use mouseMove? And if so, HOW!? Any help would be > appreciated, as I need to get this done soon. I assume you're displaying the image in a single component... if you've got it split over several in some manner, then, of course, things become rather more complex... You have to use mouseMove(). mouseEnter() is only called when you enter a component. If you want to find out when the mouse has moved into a particular rectangle in your image, you could keep an array of Rectangle objects, and then have a mouseMove() event something like public boolean mouseMove( Event e, int x, int y ) { Rectangle hotspot = null ; for ( int i=0; i < rectangles.length && hotspot == null; i++ ) if ( rectangles[i].contains( x, y ) ) hotspot = rectangles[i] ; // Mouse pointer not over one of your hotspots if ( hotspot == null ) return super.mouseMove( e, x, y ) ; // Now do something with your hotspot... etc etc etc etc... } ...where rectangles is an array of rectangles, each of which is one of your hotspots. Cheers, Giles -- "...we grisly old Sykos who have done our unsmiling bit on 'alices, when they were yung and easily freudened..." / Giles Thomas / giles@ist.co.uk / Software Engineer / IST / From csus.edu!decwrl!enews.sgi.com!news.sgi.com!howland.erols.net!feed1.news.erols.com!news.ecn.uoknor.edu!munnari.OZ.AU!news.mel.connect.com.au!news.mel.aone.net.au!usenet Thu Mar 6 06:44:43 1997 Path: csus.edu!decwrl!enews.sgi.com!news.sgi.com!howland.erols.net!feed1.news.erols.com!news.ecn.uoknor.edu!munnari.OZ.AU!news.mel.connect.com.au!news.mel.aone.net.au!usenet From: bryanb@ats.com.au (Bryan Buchanan) Newsgroups: comp.lang.java.programmer Subject: Re: Webpage counter Date: 5 Mar 1997 12:20:32 GMT Organization: wEbbTide Systems Pty Ltd Message-ID: <5fjoeg$ndl@news.mel.aone.net.au> NNTP-Posting-Host: dialup44.ats.com.au X-Newsreader: WinVN 0.93.11 In article <5en5tl$mf@news.intranet.ca>, mbadgley@intranet.ca says... > >I would like to know if it is possible to use java to create a webpage >counter, so that I won't need access to the cgi-bin directory. > >If so, could you maybe include the source, or how you made it please? > >Thanks. > >====================== > Mike Badgley > mbadgley@intranet.ca > > Pens in '97 >====================== See http://webbtide.com.au - follow the link to "Other Java Stuff" - source for the counter that displays on the first page is there. Maybe it's what you want.... Bryan From csus.edu!csulb.edu!gatech!news.mathworks.com!rill.news.pipex.net!pipex!uknet!usenet1.news.uk.psi.net!uknet!nnrp1.news.uk.psi.net!uknet!not-for-mail Thu Mar 6 06:47:30 1997 Path: csus.edu!csulb.edu!gatech!news.mathworks.com!rill.news.pipex.net!pipex!uknet!usenet1.news.uk.psi.net!uknet!nnrp1.news.uk.psi.net!uknet!not-for-mail From: Giles Thomas Newsgroups: comp.lang.java.programmer Subject: Re: gifs in applications Date: Wed, 26 Feb 1997 15:10:18 +0000 Organization: Imperial Software Technology Ltd. Message-ID: <3314525A.6400@ist.co.uk> NNTP-Posting-Host: isbalham.ist.co.uk This is a multi-part message in MIME format. --------------6B1F19FE10C9 rajiv mannath wrote: > > I'm sure this question has been posted before but I'll ask it again > anyway. I'm trying to display a gif thats on a local drive on a canvas > and I can't get it to work. This is what I have > > Canvas can = new Canvas(); > img=Toolkit.getDefaultToolkit().getImage("LogoTrans.gif"); > Graphics g = can.getGraphics(); > g.drawImage(img,0,0,can); > > I get this exception: > java.lang.NullPointerException > at CGrip.Set_Up_Panel(CGrip.java:66) > at CGrip.(CGrip.java:24) > at CGrip.main(CGrip.java:119) > > Apparently g is null. What am I doing wrong? Where should I be getting > the Grapics from? Any help would be appreciated. The problem is that the Graphics returned by getGraphics is always null until a peer (native windowing system) object has been created for the Canvas. There is another problem with your code, though - even if you somehow managed to force the Canvas to gain a peer before you called getGraphics, the effects of your draw would be lost on subsequent redraws. A simple ImageCanvas class is attached; as you can see, it keeps a pointer to an image, and paints it in the paint() method so that it can redraw the image when some part of the canvas needs repainting. Hope this is of some help. Cheers, Giles -- "...we grisly old Sykos who have done our unsmiling bit on 'alices, when they were yung and easily freudened..." / Giles Thomas / giles@ist.co.uk / Software Engineer / IST / --------------6B1F19FE10C9 Content-Disposition: inline; filename="ImageCanvas.java" import java.awt.* ; import java.awt.image.* ; public class ImageCanvas extends Canvas { private Image myImage = null ; public ImageCanvas( Image i ) { myImage = i ; } public void paint( Graphics g ) { g.drawImage( myImage, 0, 0, this ) ; } public Dimension preferredSize() { int width = myImage.getWidth( this ) ; int height = myImage.getHeight( this ) ; // Ensure the values are something sane width = Math.max( width, 1 ) ; height = Math.max( height, 1 ) ; return new Dimension( width, height ) ; } /** * A test main program to show you a demo */ public static void main( String args[] ) { // Get the image Image image = Toolkit.getDefaultToolkit().getImage( args[0] ) ; // Create an ImageCanvas to show it ImageCanvas c = new ImageCanvas( image ) ; // Wait for it to load to avoid confusion due to that... MediaTracker m = new MediaTracker( c ) ; m.addImage( image, 1 ) ; try { m.waitForAll() ; } catch ( InterruptedException ex ) { } Frame f = new Frame( "ImageCanvas test" ) ; f.add( "Center", c ) ; f.pack() ; f.show() ; } } --------------6B1F19FE10C9-- From csus.edu!csulb.edu!news.sgi.com!howland.erols.net!newsfeed.internetmci.com!axe.netdoor.com!sitrom Thu Mar 6 06:57:44 1997 Path: csus.edu!csulb.edu!news.sgi.com!howland.erols.net!newsfeed.internetmci.com!axe.netdoor.com!sitrom From: price@netdoor.com (Michael H. Price II) Newsgroups: comp.lang.java.programmer Subject: Here is how (Re: How *do* you guarantee finalization?) Followup-To: comp.lang.java.programmer Date: Mon, 24 Feb 1997 01:12:54 GMT Organization: Internet Doorway, Inc. http://www.netdoor.com Message-ID: <5eqpuo$efv$1@axe.netdoor.com> Reply-To: mhp1@ra.msstate.edu NNTP-Posting-Host: port01.stk.netdoor.com Keywords: finalizer X-Newsreader: News Xpress 2.01 // Demonstration of making your finalizer's run. (JDK 1.1) public class Test { public Test() { System.out.println("In the constructor..."); } protected void finalize() { System.out.println("In the finalizer..."); } public static void main(String args[]) { Test object = new Test(); System.out.println("In main..."); System.runFinalizersOnExit(true); } } Michael In article <5eql9j$2oc@mtinsc05.worldnet.att.net>, RichardGBaldwin@worldnet.att.net (Richard Baldwin) wrote: > From: RichardGBaldwin@worldnet.att.net (Richard Baldwin) > > In article <330F6F2A.41FC@dev5.byte.com>, Jon Udell > wrote: > >> How can I get my finalizer to run? I'm trying to use it to force a > >> disconnect of a client applet from it's server if the user closes the > >> browser instead of explicitely diconnecting or leaving the page (which > >> will disc. them). > > > >I'm puzzling over this too. > >And of course, since the finalizer must be protected, you can't call it > >from your own code. So it's a bit of a puzzle. How *do* you force > >finalization? > > I truly hope that someone responds to this post with a way to guarantee > finalization. I too have had this problem when running under Win95 with > *lots* of memory and JDK 1.0.2. From csus.edu!csulb.edu!gatech!news.mathworks.com!news.maxwell.syr.edu!feed1.news.erols.com!news.ecn.uoknor.edu!munnari.OZ.AU!comp.vuw.ac.nz!canterbury.ac.nz!not-for-mail Fri Mar 7 14:01:16 1997 Path: csus.edu!csulb.edu!gatech!news.mathworks.com!news.maxwell.syr.edu!feed1.news.erols.com!news.ecn.uoknor.edu!munnari.OZ.AU!comp.vuw.ac.nz!canterbury.ac.nz!not-for-mail From: stuart@cosc.canterbury.ac.nz (Stuart Yeates) Newsgroups: comp.lang.java.programmer Subject: Re: 'syncronized' anything Date: 26 Feb 1997 06:51:39 GMT Organization: University of Canterbury Message-ID: <5f0mhr$dka$1@cantuc.canterbury.ac.nz> Reply-To: stuart@cosc.canterbury.ac.nz NNTP-Posting-Host: 132.181.12.70 X-Newsreader: TIN [UNIX 1.3 950726BETA PL0] Jason Christiansen (jachrist@uiuc.edu) wrote: : Has anyone had some pratical experience with the syncronized keyword. : I have tried it under varing circumstances and can't seem to get the : right syntax to compile. [...] : Please help me if you can think of any constraints I might have : overlooked. Thanks in advance. the following is a small example which uses synchronized to implement semaphores. hope this helps class Semaphore { private int count; public Semaphore(int count){ this.count = count; } public synchronized void down() { while (count == 0) { try { wait(); } catch (InterruptedException e) {} } count--; } public synchronized void up(){ count++; notify(); } } -- stuart yeates aka `loam' you are a child of the kernel space no less than the daemons and the device drivers, you have a right to execute here. From csus.edu!csulb.edu!gatech!news.mathworks.com!news.kei.com!news.thenet.net!uunet!in3.uu.net!192.207.105.50!prodigy.com!usenet Fri Mar 7 14:07:03 1997 Path: csus.edu!csulb.edu!gatech!news.mathworks.com!news.kei.com!news.thenet.net!uunet!in3.uu.net!192.207.105.50!prodigy.com!usenet From: Joe Sternlicht Newsgroups: comp.lang.java.programmer Subject: Re: URLs in Applets ?? How to go there Date: Fri, 28 Feb 1997 08:38:15 -0500 Organization: Mgr, Java R&D, Prodigy Services Message-ID: <3316DFBF.109F@prodigy.net> Reply-To: reachme@pobox.com NNTP-Posting-Host: port57.fair.prodigy.net crehm@ibm.net wrote: > > If I have a URL that I want the browser to go to, how to I get it to the > browser? > > ie., if the user clicks on my java map or whatever, how do I get the browser > to load the new url. > > Chris Rehm | "This server smells like a Hormel packing plant. > crehm@ibm.net | The Spaminator has been busy." > Team OS/2 | > Get Warped or Get Bent! | - Chronicles of a Net Lord getAppletContext().showDocument(new URL("http://www.whaterver.com")); You can also add a second parameter for a target (just like in HTML you can even use _top). Make sure that if you are supporting the Macintosh and you use a target that could potentially create a new browser window that you call showDocument twice!!! =========================== Joe Sternlicht ============================= Manager, Java Development UNTANGLE Work: UNLISTED Prodigy Services THE WEB! Fax: UNLISTED 445 Hamilton Avenue PRODIGY INTERNET Prodigy: RAYC24A White Plains, NY 10601 1.800.PRODIGY mailto:reachme@pobox.com ==== Personalization, Navigation, and Intelligent Agents Department ==== From csus.edu!csulb.edu!hammer.uoregon.edu!news.uoregon.edu!news.acsu.buffalo.edu!acsu.buffalo.edu!lopes Fri Mar 7 14:07:30 1997 Path: csus.edu!csulb.edu!hammer.uoregon.edu!news.uoregon.edu!news.acsu.buffalo.edu!acsu.buffalo.edu!lopes From: lopes@acsu.buffalo.edu (Karl I. Lopes) Newsgroups: comp.lang.java.programmer Subject: Re: URLs in Applets ?? How to go there Date: 1 Mar 1997 02:25:56 GMT Organization: University at Buffalo Message-ID: <5f843k$m9d@prometheus.acsu.buffalo.edu> NNTP-Posting-Host: autarch.acsu.buffalo.edu NNTP-Posting-User: lopes X-Newsreader: TIN [version 1.2 PL2] In your mouseDown event... try{ URL u=new URL("http://....."); getAppletContext().showDocument(u); }}catch(MalformedURLException e){showStatus(e.toString());} crehm@ibm.net wrote: : If I have a URL that I want the browser to go to, how to I get it to the : browser? : ie., if the user clicks on my java map or whatever, how do I get the browser : to load the new url. : Chris Rehm | "This server smells like a Hormel packing plant. : crehm@ibm.net | The Spaminator has been busy." : Team OS/2 | : Get Warped or Get Bent! | - Chronicles of a Net Lord -- ***************************************************************** * OFFICE: * * 435 Fronzack, * * SUNY Buffalo, * From csus.edu!news.ucdavis.edu!agate!howland.erols.net!newsxfer.itd.umich.edu!uunet!in1.uu.net!192.220.251.22!netnews.nwnet.net!loki.asymetrix.com!usenet Fri Mar 7 14:11:50 1997 Path: csus.edu!news.ucdavis.edu!agate!howland.erols.net!newsxfer.itd.umich.edu!uunet!in1.uu.net!192.220.251.22!netnews.nwnet.net!loki.asymetrix.com!usenet From: SuperCede Internet Account Newsgroups: comp.lang.java.programmer Subject: Re: Extracting URL's via java Date: Mon, 03 Mar 1997 17:16:52 -0800 Organization: Asymetrix Corporation Message-ID: <331B7804.3DBA@asymetrix.com> NNTP-Posting-Host: 192.220.169.183 Karl I. Lopes wrote: > > if an URL does not exist you should get a MalformedURLException. > Mark Robert Austin (cm6072@scitsc.wlv.ac.uk) wrote: > : I am writing a little routine to check whether a url exists on the > : internet. > > : Is there any function which checks to see whether a url exists and > : returns an error code ? > > : Mark Austin - cm6072@scitsc.wlv.ac.uk > > : http ://www.scit.wlv.ac.uk/~cm6072 > -- > ***************************************************************** > * OFFICE: * > * 435 Fronzack, * > * SUNY Buffalo, * Try URL.openConnection() or URL.openStream. It throws IOException if it couldn't open a connection. ----- Jake Cormier SuperCede Technical Support Asymtrix Corporation Check out "The Fastest Java on the Planet" at http://www.asymetrix.com/products/supercede/revup.html From csus.edu!csusac!charnel.ecst.csuchico.edu!whowhere.com!olivea!spool.mu.edu!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!news.mathworks.com!europa.clark.net!newsfeeds.sol.net!ix.netcom.com!news Fri Mar 7 14:14:47 1997 Path: csus.edu!csusac!charnel.ecst.csuchico.edu!whowhere.com!olivea!spool.mu.edu!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!news.mathworks.com!europa.clark.net!newsfeeds.sol.net!ix.netcom.com!news From: Roy Epperson Newsgroups: comp.lang.java.programmer Subject: Re: URL connection to a webserver : please help! Date: Tue, 04 Mar 1997 22:04:16 -0600 Organization: Netcom Message-ID: <331CF0C0.5EEE@ix.netcom.com> NNTP-Posting-Host: chi-il14-57.ix.netcom.com X-NETCOM-Date: Tue Mar 04 8:08:23 PM PST 1997 Damien Johns wrote: > > I am trying to create an HTTP connection from my Mac to another Mac > Webserver running Webstar 2.0. I am trying to connect to an instance > of a java class that acts as a cgi. I need to be able to read from and > write to the connection. I can create the url, eg : > URL url = new URL(myurlstring); > > and > URLConnection urlConn = url.openConnection(); > > I then set the input and output variables, > urlConn.setDoOutput(true); > urlConn.setDoInput(true); > > and I can connect OK too, > urlConn.connect(); > > The problem occurs when I try to get the input stream and output > stream. The following lines are surrounded by try/catch statements, > > DataInputStream input = new DataInputStream(new > BufferedInputStream(urlConn.getInputStream())); > BufferedOutputStream buffer = new > BufferedOutputStream(urlConn.getOutputStream()); > PrintStream output = new PrintStream(buffer); > > The cgi I have written just starts up and tries to read from the HTTP > connection continually. When I run my program on my Mac, and click on > a button to connect to the Webserver, the cgi starts up on the > Webserver, and waits, but my Mac hangs, which looks like it is doing a > blocking read. If I quit Webstar on the Webserver, my Mac comes back > to life reporting an IOException : fail to read. > > If I comment out the code trying to establish streams, my Mac doesn't > hang. Also if I use a browser to connect to the cgi I wrote running on > the Webserver, things are fine too, the browser waits. I added code to > the cgi to just continually return a string, which was displayed with > no problems by the browser. I tried running my program on my Mac again > but it still wouldn't read, it just hung. > > Any suggestions!!!!!!! > > Thanks I have experienced the same problem... But have been able to get it to work with I use a fully qualified URL to the file I want AND I don't try to open an OutputStream. From csus.edu!news.ucdavis.edu!info.ucla.edu!csulb.edu!hammer.uoregon.edu!newsgate.cuhk.edu.hk!news.glink.net.hk!uunet!in2.uu.net!128.250.1.21!munnari.OZ.AU!news.mel.connect.com.au!news.ade.connect.com.au!duster.adelaide.on.net!news.camtech.net.au!ns.saard.net!fang.dsto.defence.gov.au!foxhound.dsto.gov.au!mgjw Mon Mar 10 13:12:43 1997 From: mark.webster@dsto.defence.gov.au (Mark Webster) Newsgroups: comp.lang.java.programmer Subject: Re: Help! How to pass parameters from an applet to another? Date: Wed, 26 Feb 97 00:02:35 GMT Organization: Defence Science and Technology Organisation (Australia) Message-ID: <5evr0e$f3r@foxhound.dsto.gov.au> NNTP-Posting-Host: mgjw.dsto.defence.gov.au X-Newsreader: News Xpress Version 1.0 Beta #4 Path: csus.edu!news.ucdavis.edu!info.ucla.edu!csulb.edu!hammer.uoregon.edu!newsgate.cuhk.edu.hk!news.glink.net.hk!uunet!in2.uu.net!128.250.1.21!munnari.OZ.AU!news.mel.connect.com.au!news.ade.connect.com.au!duster.adelaide.on.net!news.camtech.net.au!ns.saard.net!fang.dsto.defence.gov.au!foxhound.dsto.gov.au!mgjw In article <330D6A94.4848@xtel.it>, Cristiano Leoni wrote: >(Extending existing applets of which you don't >have the code but just know the parameters' name) > >Suppose you have an applet which gets three parameters named >first/second/third. Suppose you wuold call it from HTML with a stuff >like: > > > > > > >Now, how would you call that applet from inside another applet (i.e. >extending it), specifying each parameter a value (1/2/3) ? > >Any suggestions and ideas are greatly appreciated. If it's any help have a look at http://www.sd.monash.edu.au/~scott/java/Lectures/Lecture6/AppletAppletCommunic ation.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark Webster +613 9626 8256 DEFENCE SCIENCE & TECHNOLOGY ORGANISATION, AUSTRALIA AKA: http://www.adgrafix.com/info/mwebster ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DISCLAIMER: The contents of this message do not necessarily represent the Commonwealth of Australia or the Australian Department of Defence. From csus.edu!csulb.edu!gatech!news.mathworks.com!europa.clark.net!newsfeeds.sol.net!uwm.edu!lll-winken.llnl.gov!fnnews.fnal.gov!newsfeed.pnl.gov!cebaf4.cebaf.gov!news Mon Mar 10 13:20:37 1997 Path: csus.edu!csulb.edu!gatech!news.mathworks.com!europa.clark.net!newsfeeds.sol.net!uwm.edu!lll-winken.llnl.gov!fnnews.fnal.gov!newsfeed.pnl.gov!cebaf4.cebaf.gov!news From: Andy Kowalski Newsgroups: comp.lang.java.programmer Subject: Re: How to execute a UNIX command? Date: Fri, 28 Feb 1997 17:07:42 -0500 Organization: CEBAF Message-ID: <3317572E.2664@cebaf.gov> NNTP-Posting-Host: cebafh.cebaf.gov Daisy Wu wrote: > Hi, > Here is my problem: > > How do I execute a unix command such as "ls -al" within a Java program? > If I were able to successfully execute such command, what will be returned, and how do > I save the returned values? > > Many thanks. > ---- > Daisy Try using String cmd = "/bin/ls -la"; Process unixcmd = Runtime.getRuntime().exec(cmd); Then you can access it with the Process methods: unixcmd.destroy() unixcmd.exitValue() unixcmd.getErrorStream() unixcmd.getInputStream() unixcmd.getOutputStream() unixcmd.WaitFor() -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Andy Kowalski | _/_/_/_/_/ _/_/_/_/_/ _/ _/ _/_/_/_/ _/_/_/_/ | _/ _/ _/_/ _/ _/ _/ _/ kowalski@cebaf.gov | _/ _/ _/ _/ _/ _/_/_/_/ _/_/ | _/ _/ _/ _/ _/_/ _/ _/ _/ Phone: 757.269.6224 | _/ _/_/_/ _/ _/ _/ _/ _/ FAX: 757.269.7053 | TJNAF - Thomas Jefferson National Accelerator Facility -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= From csus.edu!csulb.edu!hammer.uoregon.edu!news.texoma.net!zephyr.texoma.net!uunet!in1.uu.net!192.108.254.3!news.teleport.com!not-for-mail Mon Mar 10 13:21:25 1997 Path: csus.edu!csulb.edu!hammer.uoregon.edu!news.texoma.net!zephyr.texoma.net!uunet!in1.uu.net!192.108.254.3!news.teleport.com!not-for-mail From: Jenni Lateiner Newsgroups: comp.lang.java.programmer Subject: Re: DRAG AND DROP in Java Date: Fri, 28 Feb 1997 17:54:56 -0500 Organization: Jenni Consulting Group Message-ID: <33176240.7B97@dataspace.com> Reply-To: jenni@dataspace.com NNTP-Posting-Host: ip-pdx02-04.teleport.com Dirk P. Fromhein wrote: > > Not really an answer, but check out Netscape's IFC (Internet Foundation > Classes). They provide very good drag and drop support. > > http://developer.netscape.com > > Dirk Fromhein > df@watershed.com > http://www.watershed.com > > David Trinler wrote: > > > > How do you drag and drop Images from one component to another? Is there > > a way to get the root window so that you can draw the image X'ored into it > > as you are dragging? Is there some other way to do it? > > > > Thanks in advance, > > Dave Trinler There's also a quicky example online of drag-drop image movement. Look at the dragDrop example on: http://www.dataspace.com/jenni/ifc/index.html -Jenni -- Jennifer Lateiner Oak Tree Publications jen@otp.com http://www.otp.com/ Jenni Consulting Group jenni@dataspace.com http://www.dataspace.com/jenni/ From owner-sigcse.members@ACM.ORG Fri Feb 6 10:46 PST 1998 Message-Id: <199802061831.NAA66744@mail.acm.org> Date: Fri, 6 Feb 1998 13:21:43 -0500 Reply-To: Kim Bruce From: Kim Bruce Subject: Parameter passing in Java Those whose only experience with OO language is C++ (or perhaps Object Pascal) are generally unaware that the Java way of passing parameters is the standard for pure OO languages. At a low-level it might be called "call-by-value", but a more accurate name might be "call-by-sharing". The low-level description is accurate because one cannot assign to a parameter (or at least not have the new value returned to the caller). This reflects the OO philosophy that an object only is allowed to directly change its own features. It must ask others to change themselves. Thus the only way one can change a parameter is to send messages to it, asking it to modify itself. An important reason for restricting to this kind of parameter passing is that subtyping of parameters breaks otherwise. Suppose o has a method m with parameter x of type C. Now suppose in the body of m there is an assignment "x = new C();". If this assignment were to be reflected back to the caller no subtyping would be possible. E.g., if D is a subclass of C and d referred to an object of D, then when o.m(d) returned, d would hold an object of type C and not D, breaking type-safety. A language like C++ deals with this by all sorts of truncations, hidden constructors, casts, etc., resulting in a situation which is very hard to figure out. True OO languages like Java, Eiffel, and Smalltalk avoid these problems by only having call-by-sharing. I would also recommend not describing int's as objects. They are only objects in an ADT way. Their operations are external to the objects themselves. The (admittedly annoying) contrast between ints and INTEGERs in Java illustrates the differences. Responding to the original message which started this thread ... Java became hot because of very clever marketing decisions: Programming for the web and adopting C/C++ syntax to suck in C/C++ programmers who would then feel that it would be easy to learn. Don't be fooled too much by that P.R. There really is a fairly different language lurking under that syntax (i.e., the syntax is similar, but the semantics are quite different). I happen to think that semantically it is really quite a good language (and I hate the syntax!). It is missing support for parameterized types, but that will come. Similarly, the web stuff is fun and glitzy, but more important are the easy to use libraries for GUI programming (whether for applets or applications - and the 1.1. libraries are a great improvement over the earlier ones), and features supporting concurrency, etc. From the viewpoint of the libraries it is still somewhat unstable (I'm using the 1.1 libraries this term for the first time, and I expect we'll be using the Swing libraries the next time), but those don't really affect the core language and after 1.1, won't have much impact at all as the style will remain the same. Let's face it, anyone teaching Java last year was on the bleeding edge, this year we're leading edge, by next year it's going to be fairly routine. The main advantage is the great improvement of Java over C++ and Object Pascal that led many of us to adopt it early in spite of the risks. There are other reasonable languages like Eiffel or Ada, but other reasons lead me to prefer Java. Kim Bruce From jholsonb Thu Jun 4 09:59 PDT 1998 Date: Thu, 4 Jun 1998 09:59:33 -0700 From: jholsonb (John Dean Holsonbake) Message-Id: <199806041659.JAA08392@orion.csusb.edu> Subject: Re: CS320: Java garbage collection Java schedules its garbage collection for two different times. Most of the time, Java does its garbage collection while the program is idle (usually waiting for input from user, hard drive, another computer, etc.) Also, java can "see" when its resources are getting low (RAM). When it can tell this, it will also perform its garbage collection (under this circumstance, you might notice a small delay or pause.) Dean From jnorris@csci.csusb.edu Mon Mar 20 13:33:59 2000 Message-ID: <38D5B980.6DE843BA@csci.csusb.edu> Date: Sun, 19 Mar 2000 21:39:12 -0800 From: Jeffeory Norris Reply-To: norrisj@mindspring.com Organization: JMN X-Accept-Language: en MIME-Version: 1.0 Subject: Problem running a Java applet http://java.sun.com/openstudio/applets/clock.html I tried to run this applet on nec358-28.csci.csusb.edu using the latest version of Netscape and it would not run. I tried it on nec358-27.csci.csusb.edu, and it worked! This is truley strange... Anyway thought you may be interested. Jeff From dick Thu Mar 28 11:27 PST 1996 From: dick (Dr. Richard Botting) Date: Thu, 28 Mar 1996 10:54:40 -0800 Subject: (fwd) Re: "cpu eaters" with java threads Newsgroups: comp.lang.java Organization: CS Dept., Calif. State Univ., San Bernardino Path: csus.edu!csusac!charnel.ecst.csuchico.edu!psgrain!newsfeed.internetmci.com!news.ac.net!news.cais.net!nntp.uio.no!ifi.uio.no!news.sics.se!news From: Jari Ojala Newsgroups: comp.lang.java Subject: Re: "cpu eaters" with java threads Date: Wed, 27 Mar 1996 16:53:13 +0100 Organization: Swedish Institute of Computer Science, Kista Message-ID: <31596469.6CD1@sics.se> NNTP-Posting-Host: 192.16.123.56 I forward this Ingo Wechsung's message: --cut here Subject: Re: "cpu eaters" with java threads Date: Wed, 27 Mar 1996 16:17:11 +0100 From: Ingo Wechsung Organization: CAS Nord GmbH To: Jari Ojala Jari Ojala wrote: > > My point was here that you *can't* stop the counter. I can use > your computer as a resource for my own private purposes. > The counter will continue as long your netscape process is running. > Eaven while you read other web pages or load other applets the > counter thread will stay on. I could use this bug/feature to > use your computer as a resource in my private > computations and you don't have any way to stop me.. :) > You are absolutely right. If I could post, I'd have done this, but unfortunately I am limited to read news only. Yesterday, I checked the number of threads netscape had before and after consulting some pages with applets. When I start a fresh copy of netscape, there are initially 3 threads. After only half an hour I had 18 threads, some of them still eating cpu. The bad thing is, that the browser user can't do anything about bad programming style (or intentional written unstopping applets). I think this is an area, where people should think again about an applets lifecycle. Please feel free to post this to comp.lang.java if you like. Ingo -- Email: iw@return-online.de Tel.: 07121/928624 Fax.: 07121/928686 CAS Nord GmbH, Geschaeftsstelle Reutlingen -- Return Online GmbH Friedrich-Ebert-Str. 3, 72762 Reutlingen, Germany Please have a look at our Web pages: http://www.return-online.de -- dick botting http://www.csci.csusb.edu/dick/signature.html Disclaimer: CSUSB may or may not agree with this message. Copyright(1996): Copy freely but say where it came from. I have nothing to sell, and I'm giving it away. From prolog-request@swi.psy.uva.nl Mon Apr 3 02:09:11 2000 Resent-Date: Mon, 3 Apr 2000 11:06:17 +0200 (MET DST) Posted-Date: Mon, 3 Apr 2000 10:52:54 +0100 (WET DST) From: Lionel Ains Message-ID: <954749064008022@caramail.com> X-Originating-IP: [194.202.131.4] Subject: CGI with SWI-Prolog Date: Mon, 3 Apr 2000 10:50:02 GMT+1 Resent-Message-ID: Resent-From: prolog@swi.psy.uva.nl X-Mailing-List: archive/latest/553 X-Loop: prolog@swi.psy.uva.nl This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --=_NextPart_Caramail_008022954749064_ID Hello, I am trying to use SWI-Prolog as a CGI script. To get the post parameters, I would like to read from the stdin without Prolog printing ':|'. I found out that this was possible by trying to get the input when not on an empty line. How could I do that in any cases (when the cursor is at the begining of the line)? Is there a non-blocking way to detect the when nothing is sent to the user input (script called without parameter)? Are there available librairies to handle the URL encoding/decoding? Many thanks, Lionel _______________________________________________________ Vendez tout... aux ench=e8res - http://www.caraplazza.com --=_NextPart_Caramail_008022954749064_ID-- ---------------- * To UNSUBSCRIBE, please use the HTML form at http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist or send mail to prolog-request@swi.psy.uva.nl using the Subject: "unsubscribe" (without the quotes) and *no* message body. ** An ARCHIVE of this list is maintained at http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/ From prolog-request@swi.psy.uva.nl Mon Apr 3 03:02:53 2000 Resent-Date: Mon, 3 Apr 2000 11:53:50 +0200 (MET DST) From: Lukas Faulstich MIME-Version: 1.0 Message-ID: <14568.26436.13071.661572@inf.fu-berlin.de> Date: Mon, 3 Apr 2000 11:41:23 +0200 (MET DST) CC: prolog@swi.psy.uva.nl Subject: CGI with SWI-Prolog In-Reply-To: <954749064008022@caramail.com> Reply-To: faulstic@inf.fu-berlin.de Resent-Message-ID: Resent-From: prolog@swi.psy.uva.nl X-Mailing-List: archive/latest/554 X-Loop: prolog@swi.psy.uva.nl --7/ZKyvzVh+ Content-Description: message body and .signature Lionel Ains writes: > Hello, > > I am trying to use SWI-Prolog as a CGI script. > To get the post parameters, I would like to read from the > stdin without Prolog printing ':|'. > I found out that this was possible by trying to get the > input when not on an empty line. > How could I do that in any cases (when the cursor is at the > begining of the line)? % switch off the prompt: prompt(_, '') > Is there a non-blocking way to detect the when nothing is > sent to the user input (script called without parameter)? > Are there available librairies to handle the URL > encoding/decoding? it is easier to use Java Servlets to let them do this job. This has the advantage that you can maintain a stateful prolog process that handles multiple http requests. While there is the jpl library for calling prolog from within java , I found it easier to use standard input/output for communication. You might have a look at the attached Java/Prolog source code. Hope that helps- Lukas -- Lukas C. Faulstich faulstic@inf.fu-berlin.de Institut fuer Informatik +49 (30) 838 - 75 123 Freie Universitaet Berlin +49 (30) 838 - 75 109 (fax) Takustr. 9 http://www.inf.fu-berlin.de/~faulstic D-14195 Berlin, Germany PGP key: see my homepage --7/ZKyvzVh+ Content-Description: prolog backend Content-Disposition: inline; filename="servlet.pl" /* * $Id: servlet.pl,v 1.9 1999/11/14 21:31:46 faulstic Exp $ * * (c) Lukas Faulstich * * Description: backend for servlet * */ :- module(servlet, [ servlet_loop/0 ]). servlet_loop:- % redirect user_error to current output current_output(CurrentOut), dup_stream(CurrentOut, user_error), % switch off the prompt: prompt(_, ''), % start the loop next. next:- read_action(Action, Bindings), handle(Action, Bindings). handle(http_request(Parameters), _):- !, http_request(Parameters), next. handle(syntax_error, _):- !, error('Syntax Error', []). handle(welcome, _):- !, welcome, next. handle(next, _):- !, fail. handle(halt,_):- !, halt. handle(end_of_file,_):- !, halt. handle(done,_):- !. handle(Action,_):- error('Don\'t understand ~w', [Action]), next. http_request(Attributes):- member(halt=true, Attributes), !, base_url(BaseURL), format('Halt

Halt

The system has been halted. ~n~n', []), halt. http_request(Attributes):- http_request(Attributes):- decode_attributes(Attributes, DecodedAttributes) % use DecodedAttributes = [Attr1=Val1,...,Attrn=Valn] % to generate HTML page and % print it to standard output, e.g.: format('Attributes

Attributes:

~w~n~n', [DecodedAttributes]), decode_attributes([], []). decode_attributes([A=V|AVs], [A=T|ATs]):- (atom_to_term(V,T,_) -> true; T=V), decode_attributes(AVs, ATs). error(Message, Args):- format('Error~n

Error:

'), format(Message, Args), format('~n~n'). remake:- format('Make

Make:


'), 
	make, 
	format('

~n~n'). welcome:- http_request([]). read_action(Action, Bindings):- read_line_term(Action, Bindings), !. read_action(end_of_file, []). read_line_term(Term, Bindings):- read_line(Line), (atom_to_term(Line, Term, Bindings) -> true; Term= syntax_error, Bindings=[]). read_line(Line):- get0(Char), Char \= -1, read_line_chars(Char, Chars, []), name(Line, Chars). read_line_chars(10) --> !, []. read_line_chars(-1) --> !, []. read_line_chars(C) --> [C], { get0(N) }, read_line_chars(N). --7/ZKyvzVh+ Content-Description: Java front end Content-Disposition: inline; filename="PrologServlet.java" // Frontend Servlet for SWI Prolog (servlet.pl) import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public final class PrologServlet extends HttpServlet { Process backEnd= null; PrintWriter backEndInput= null; BufferedReader backEndResults= null; PrintWriter logWriter= null; public String getServletInfo() { return "Frontend for SWI Prolog (servlet.pl)"; } public void init(ServletConfig config) throws ServletException { String logFileName; super.init(config); initBackEnd(); if ((logFileName = getInitParameter("logfile")) == null) { // throw new UnavailableException (this, "No log file given!"); } else { try { logWriter= new PrintWriter(new FileOutputStream(logFileName), true); } catch (IOException e) { throw new UnavailableException (this, "Cannot open log file " + logFileName + "!"); } } } public void initBackEnd() throws ServletException { String tmpdir=getInitParameter("tmpdir"); if (tmpdir == null) { tmpdir = "/tmp"; } String set_tmpdir="TMPDIR="+(new File(tmpdir)).getAbsolutePath(); String servletName=getInitParameter("servletname"); String[] envp; if (servletName==null) { String[] tmp_envp= {set_tmpdir}; envp= tmp_envp; } else { String[] tmp_envp= {set_tmpdir, "SERVLET_NAME="+servletName}; envp= tmp_envp; } String backEndCall=null; if ((backEndCall = getInitParameter("backend")) == null) { backEndCall = "HyperView"; } try { backEnd = Runtime.getRuntime().exec(backEndCall, envp); backEndInput = new PrintWriter(backEnd.getOutputStream(), true); backEndResults = new BufferedReader(new InputStreamReader(backEnd.getInputStream())); } catch(IOException e) { throw new UnavailableException (this, "Cannot initialize back end!"); } } public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException { doGet(req, res); } public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException { String action; boolean result; // Set Content Type: res.setContentType("text/html"); // get output stream to client PrintWriter servletOut = null; try { servletOut = res.getWriter(); } catch (IOException e) { log("Failed to establish output stream to client"); return; } if(!forwardRequest(req, servletOut)){ log("Pipe failed. Trying to restart backend..."); closeBackEnd(); initBackEnd(); log("... backend restarted."); if (!forwardRequest(req, servletOut)){ log("Pipe failed."); servletOut.println("Fatal Error

Fatal Error

Failed to (re)start the HyperView Server."); } } servletOut.close(); } public boolean forwardRequest(HttpServletRequest req, PrintWriter servletOut){ backEndInput.print("http_request("); printParameters(req, backEndInput); backEndInput.println(")."); log("Request sent."); return pipePage(backEndResults, servletOut); } public void printParameters(HttpServletRequest req, PrintWriter out){ int j=0; Enumeration e = req.getParameterNames(); log("Parameters:"); out.print('['); while (e.hasMoreElements()) { String name = (String)e.nextElement(); String vals[] = (String []) req.getParameterValues(name); if (vals != null) { for (int i = 0; i 0) { out.print(','); } out.print(name + "="); log(name + "= \"" + vals[i] + "\""); printAtom(out, vals[i]); j++; } } } out.print(']'); } public void printAtom(PrintWriter out, String atom) { int i, l=atom.length(); char c; out.print('\''); for (i=0; i Date: Mon, 03 Apr 2000 18:15:01 +0100 From: Paul Singleton Organization: SmartArts Computing Consultancy X-Accept-Language: en MIME-Version: 1.0 Subject: Re: CGI with SWI-Prolog Resent-Message-ID: Resent-From: prolog@swi.psy.uva.nl X-Mailing-List: archive/latest/556 X-Loop: prolog@swi.psy.uva.nl Lukas Faulstich wrote: > Lionel Ains writes: > > ... > > Is there a non-blocking way to detect the when nothing is > > sent to the user input (script called without parameter)? > > Are there available librairies to handle the URL > > encoding/decoding? > it is easier to use Java Servlets > > to let them do this job. This has the > advantage that you can maintain a stateful prolog process that handles > multiple http requests. This has other potential advantages, e.g. that someone else does quite a bit of the work for you, takes responsibility for fixing bugs, and handles lots of nitty gritty details of HTTP requests and responses that you may need to handle if/when your application matures, e.g. sessions, cookies, authentication... If you want to play with servlets, I recommend donwloading Tomcat 3.0 from www.apache.org: this an all-Java servlet host which also acts as a rudimentary Web server (i.e. you don't need Apache as well). > While there is the jpl library for calling > prolog from within java > , I found it easier > to use standard input/output for communication. OK but I've got it to work with JPL, and you're welcome to reuse my code (I'll email it to anyone who asks). [potential disadvantage of the JPL approach: the Java VM shares memory with the JPL library, the Prolog VM and any foreign code loaded by it, and is thus vulnerable to corruption; i.e. commercial or corporate Web servers may reasonably refuse to host servlets which load Java "native methods"] Basically, a servlet's "doGet" method is called when a GET request arrives; it is passed a "request" object and a "response" object; the method body (which you write) extracts whatever info it needs from the request object, stashes its output (HTML, cookies etc.) into the response object, and returns. To couple this generically to Prolog I've tried to convert the request object to a Prolog term, pass it to a Prolog "doGet" goal which should succeed at most once, returning a response term which I convert (or interpret) into a response object. public void doGet( do_get( HTTP GET --> HttpServletRequest request, --> +Request, HttpServletResponse response --> -Response ) ) :- For now at least, the request term contains just about every detail of the request object (I don't think it costs much to construct this, and it's simpler than calling back into Java to get the details on demand) as a "list-of-pairs" map (some of whose values are similar maps): Request = [ secure-false, method-'GET', context_path-'/examples', query_string-'a0=proc&a1=pcm13&a2=pcm_2000&a3=0', request_uri-'/examples/servlet/WebGoal', servlet_path-'/servlet/WebGoal', protocol-'HTTP/1.1', remote_addr-'10.1.1.36', remote_host-'radford.smartarts.co.uk', scheme-http, server_name-radford, server_port-8080, headers-[ 'User-Agent'-'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT; JungeLink)', 'Accept'- */*, 'Host'-'radford:8080', 'Accept-Encoding'-'gzip, deflate', 'Accept-Language'-'en-gb', 'Referer'-'http://radford/index.html', 'Connection'-'Keep-Alive' ], parameters-[ a2-pcm_2000, a1-pcm13, a0-proc, a3-'0' ], locales-[ locale(en,'GB','') ] ] and you can pull stuff out of this with e.g. memberchk/2 NB the Servlet API enumerates parameters in no particular order NB some of these atom values could be parsed into terms, but I'd rather do this in Prolog than in Java NB this request term could be written to a pipe or socket in Lukas' idiom, i.e. it's not peculiar to the JPL approach... NB there are still some details of a request which are not readily passable by value as above, but I haven't worried about them (I lack motivation, being nowhere near needing them yet :-) Paul Singleton ---------------- * To UNSUBSCRIBE, please use the HTML form at http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist or send mail to prolog-request@swi.psy.uva.nl using the Subject: "unsubscribe" (without the quotes) and *no* message body. ** An ARCHIVE of this list is maintained at http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/ From owner-sigcse.members@ACM.ORG Fri Apr 7 10:56:01 2000 Message-Id: <200004071756.NAA06262@mail.acm.org> Date: Fri, 7 Apr 2000 10:15:53 -0700 Reply-To: Sharon Tuttle From: Sharon Tuttle Subject: Java SUMMARY from very old: Re: Java and Theory textbooks query In-Reply-To: Last semester, I sent out a request for suggestions for texts for two of my courses. I was quite remiss in not yet summarizing the responses, BUT I know that our bookstore here is now asking for Fall 2000 textbooks, so I hope that this summary will still be of interest at this late date. This part covers the Java textbook portion of that original query. PART 1: JAVA TEXT SUGGESTIONS TEXTS MENTIONED: (in "chronological" order of mention in replies) Deitel and Deitel, "Java How To Program", Third Edition: 2 references Bell and Parr, "Java for Students", Prentice-Hall: 1 reference van der Linden. "Just Java 2", 4th ed., Prentice-Hall, ISBN 0-13-010534-1: 1 reference Budd, "Understanding Object-Oriented Programming with Java", Addison-Wesley: 2 references Budd, "C++ for Java Programmers", Addison-Wesley: 1 reference Winston, "On to Java": 1 reference (and 1 mention of using their own notes, supplemented by Deitel and Deitel "for those who must have a text".) DETAIL: Deitel and Deitel, "Java How To Program", Third Edition: 2 references EXCERPTED COMMENTS: "I use Deitel & Deitel, "Java: How to Program" (3rd ed). It's not the perfect book -- it aims at non-academic users, CS I, and more advanced academic users. The sections on control structures and basic programming are wasted for my class. However, I like the early use of graphics and the deferral of O-O details such as abstract classes and polymorphism. It has a nice balance of dazzle to substance." Bell and Parr, "Java for Students", Prentice-Hall: 1 reference EXCERPTED COMMENTS: "Check out *Java for Students* by Bell and Parr (Prentice-Hall). We use it in a self-paced Java-as-a-second language course, for which it seems to work fine and satisfies all your points; in particular, the book starts with applets and doesn't get to applications until rather late. Its major flaw is that it doesn't mention much of anything about java.utils." van der Linden. "Just Java 2", 4th ed., Prentice-Hall, ISBN 0-13-010534-1: 1 reference EXCERPTED COMMENTS: "I can't directly speak to your desires, but our students are using this book and like it a lot. They're more advanced than your sophomores, having 2 quarters of C++ with lots of data structures ... but wouldn't hurt to check it out. I'm not teaching the course, just word of mouth." Budd, "Understanding Object-Oriented Programming with Java", Addison-Wesley: 2 references EXCERPTED COMMENTS: "This might be a bit off-topic, but I've used Tim Budd's "Understanding Object-Oriented Programming with Java" (A-W) a couple of times. His presentation has a bit of a design orientation, but it's the best concise intro to Java (both the language and basic libraries) that I've seen. Applets are done late, but I think it would be easy enough to do them early if you want." "Budd has another book, OOP using Java, which has nice example programs (a pinball construction game for example)." Budd, "C++ for Java Programmers", Addison-Wesley: 1 reference EXCERPTED COMMENTS: "Have you considered Budd's book "C++ for Java programmers" (it can also be used as a Java for C++ programmers)? This book goes into detail about the subtle differences between the two languages (in terms of memory management for example). It is published by Addison Wesley. I haven't read the entire book but it looks useful as a supplementary book since it does not claim to cover either language in great detail." Winston, "On to Java": 1 reference EXCERPTED COMMENTS: "I don't have any good ideas about the Java text, except to mention Winston's On To Java - I think it is by far the best intro to Java for students who can already program. It's also really cheap. Unfortunately, it doesn't meet any of your other wishes - about applets, etc." APPENDIX: Finally, here is the original query: -------------------------------------------- On Fri, 29 Oct 1999, Sharon Tuttle wrote: > > Well, it is Spring 1999 textbook ordering time here, at least, and I've > already missed the first bookstore deadline. 8-) > > In the hopes that a few folks here might have a strong opinion they'd like > to share, I'm asking for textbook opinions for two different courses: > > First course - CIS 235 - Java Programming > Assumptions: > * the course is a Sophomore-level programming course > * it is introducing Java to students who have had C++ in > a CS0/part of CS1 course (the only prerequisite) > * majors can take this as an elective, and it is a course > minors often take as well > * I really don't want to use a CS0/CS1 text --- I'd prefer a > Java-as-an-Nth-language text > * I really want applets to be covered early, not in Chapter 10 > * I'd really prefer a text that doesn't use this-text-only > classes for I/O > * I currently jump-around in "Problem Solving with Java" by > Koffman and Wolz, which looks like a very nice CS1 text, > but see above > > If anyone has a book that they like that meets the above assumptions, I'd > love to hear about it. If anyone simply has a favorite Java book, period, > then I'd be interested in hearing about it even if it doesn't meet the > above. 8-) > > Second Course - CIS 480 - Computer Theory > Assumptions: > * We hope to offer a Computer Science degree some day, but in the > meantime, we're trying offering this as an elective to > interested and broad-minded CIS majors > * I want to cover the basics of Computer Theory, which I > persist in thinking is useful for anyone in the computing > field 8-) > * I do not mind skimping a bit on the proofs... > * I currently use "Introduction to Automata Theory, Languages, > and Computation" by Hopcroft and Ullman, which is a > venerable classic, but surely a more ... accessible? > ...text has come out in this area since 1979? > > Any suggestions here would be greatly appreciated. I have been trying to > decide for a semester if Sipser's "Introduction to the Theory of > Computation" is an improvement. I don't think Lewis and Papadimitriou's > "Elements of the Theory of Computation" is. Any of these three texts look > like they'd be fine for a graduate-level CS course, but I keep hoping > there's an undergraduate-level text suitable for CIS students as well as > CS and Math majors. > > I will post a summary of replies if I get any, so if you would not like > your reply included in such a summary, please let me know. > > And if anyone wants my opinions of CIS database texts or CIS systems > design/capstone texts, I'd be happy to provide them. > > Thank you very much! > > -- Sharon Tuttle > Department of Computing Science > Humboldt State University ------------------------------------------------------------ > From owner-sigcse.members@ACM.ORG Mon Apr 10 09:30:37 2000 Message-Id: <200004101630.MAA84194@mail.acm.org> Date: Mon, 10 Apr 2000 12:31:01 -0400 Reply-To: Michael Feldman From: Michael Feldman Subject: Write it in Ada; run it on your Java Virtual Machine Hi all, Those of you who visited the SIGAda exhibit at SIGCSE 2000 saw (and maybe played) our ConnectFour "gnapplet", a Java JVM applet written in Ada 95. I'm writing now just to pass on to SIGCSE folks that Ada Core Technologies (ACT) has recently released the compiler that produced our gnapplet. This is called JGNAT, a version of GNU Ada 95 (GNAT) that generates byte code for the Java Virtual Machine. JGNAT, like all the GNAT compilers and tools, is fully open-source and freely downloadable and distributable. The JGNAT release comes with - binary releases for Windows, Solaris, and Linux - complete sources: JGNAT is written in Ada and can be compiled using the current release of GNAT, the GNU Ada 95 compilation system - a number of interesting examples of JVM applications and "gnapplets" - a complete set of Ada package specs for the JavaTM 2 Platform, Standard Edition, v1.2.2 API Specification. This set of specs can be used to write JVM applications and applets in Ada, using the full power of the Java Application Program Interfaces (APIs). See http://www.acm.org/sigada/education for a front-page link to all the info on this exciting development. I have no connection to ACT; I'm just a satisfied customer! Mike Feldman From rjbotting@aol.com Mon Apr 17 13:14:35 2000 From: rjbotting@aol.com (Richard J. Botting) Newsgroups: comp.lang.misc Date: 17 Apr 2000 20:17:24 GMT Organization: AOL http://www.aol.com Subject: Re: How do i put java in my page??? Message-ID: <20000417161724.01422.00000833@ng-fx1.aol.com> >Christopher Hahn wrote: > >> Here is the URL and the html code for a working >> reference: >> ======= >> http://www.eleganceintime.com/applets/calculation.html >> ======= >> > CODE="jsolitaire/calculation/Calculation.class" HEIGHT=450 WIDTH=680> >> JSolitaire Calculation requires a java-enabled browser >> >> ======= >> >> Now, moving the html file up out of the applets subdirectory >> and changing its reference yields: >> ======= >> http://www.eleganceintime.com/calculation.html >> ======= >> > CODE="applets/jsolitaire/calculation/Calculation.class" HEIGHT=450 >WIDTH=680> >> JSolitaire Calculation requires a java-enabled browser >> >> ======= >> >> Now this second reference fails with the error: >> "Applet applets/jsolitaire/calculation/Calculation error: >> java.lang.ClassFormatError: Wrong class name inside class file" >> >> WHY! >> > >As far as I can see, you have forgotten to enter the CODEBASE tag into your >applet code. It is a tag that will tell the html client (or browser, what you >like to call it) that parses the HTML to search for the applet code in a >specific >directory. Information about this addition to the applet tag can be found in >any >book about html. If you still can not find it, mail me, and I will copy it >and >send it to you. > >grtz, Arjen aka Dwaal > > > > > > > > > >Subject: Re: How do i put java in my page??? >Path: >lobby!newstf02.news.aol.com!portc01.blue.aol.com!portc.blue.aol.com!bigne ws.mediaways.net!news.algonet.se!newsfeed1.telenordia.se!algonet!uab.erics son.se!erinews.ericsson.se!newstoo.ericsson.se!not-for-mail >From: "Arjen Reudink (ETM)" etmarre@etm.ericsson.se >Newsgroups: macromedia.dreamweaver, comp.lang.java, comp.lang.help, >comp.lang.misc >Date: Mon, 17 Apr 2000 16:47:57 +0200 >Organization: Ericsson >Message-ID: <38FB241D.B44402CE@etm.ericsson.se> ><38F11D91.A7D90211@eleganceintime.com> >NNTP-Posting-Host: dino.etm.ericsson.se >X-Accept-Language: en >Xref: lobby macromedia.dreamweaver:79536 comp.lang.misc:23386 > > rbotting at CSUSB edu Computer Scientist, Sys Admin, Consultant, Researcher, and Reviewer http://www.csci.csusb.edu/dick From dick@csci.csusb.edu Tue Apr 25 13:51:52 2000 Message-ID: <390606AE.CF254AC3@csci.csusb.edu> Date: Tue, 25 Apr 2000 13:57:18 -0700 From: Dick Botting Reply-To: dick@csci.csusb.edu Organization: CSUSB X-Accept-Language: en MIME-Version: 1.0 Subject: sodaconstructor http://www.sodaplay.com/constructor/