Programming - Java


Subject:Communicating between 2 browser frames
From: Supernova<ngqweeli@comp.nus.edu.sg>

Tim <tanyongj@comp.nus.edu.sg> wrote:
> How do I do that?
You can try defining another class with static member data variables.
Then the two applets wishing to communicate will reference those static
variables.

This is works in jdk1.1.x. I'm not sure about Platform 2.

From: DoCoMo <khoohuit@comp.nus.edu.sg>
Subject: [java] right mouse click?
Date: 14 Jan 1999 17:49:58 GMT

hi! may i know how to detect a right mouse click?
From: ngcheepi@comp.nus.edu.sg (Dry Ice)
Date: Thu, 14 Jan 1999 19:28:23 GMT

Sure you wanna do?
Java code is supposed to be cross platform, and Mac mouse has only one
button.
From: Derek Kiong Beng Kee <dkiong@comp.nus.edu.sg>
Date: 15 Jan 1999 03:17:00 GMT

see java.awt.Event

From: Tim <tanyongj@comp.nus.edu.sg>
Subject: [java] instance variable?
Date: 15 Jan 1999 02:55:59 GMT

What does this error message mean?

Attempt to reference method toString in class [classname] as an instance
variable.
From: Derek Kiong Beng Kee <dkiong@comp.nus.edu.sg>
Date: 15 Jan 1999 03:14:11 GMT

You forgot your () in toString ??

From: "InSaNe" <limdauhe@comp.nus.edu.sg>
Subject: [JAVA]
Date: Mon, 18 Jan 1999 17:58:23 +0800

i am new to java and have a question. few programmers use java to create
applications coz it is slow. this is because when we compile the source
code, it becomes bytecode and needs a interpreter to run. in this way it is
platform independent.

this is different from programs compile in other languages like c because
when we compile it, it becomes machine code and can be run pretty fast on
that specifc platform.

what i want to know is why doesnt't java have a different compiler for each
platform instead. so we can have a few native compiler(eg a windows java
compiler and a mac java compiler). then when we compile the source code
using the windows java compiler, it will become machinecode instead of
bytecode. this program will only be able to run on the windows platform.
however we can use the same source code and then compile it under the mac
java compiler. the compiled program can only be run under mac. this way
won't it be able to execute faster without the need of a interpreter and
won't it be platform independent as well?
From: Long Zai Jiang Hu <chinhong@comp.nus.edu.sg>
Date: 18 Jan 1999 10:24:11 GMT

Do you think this is convenient for users?
Java compilers that have to be downloaded/installed before java applets/code can be run?
Why not have one to do the job for all?
From: Lai Zit Seng <laizs@comp.nus.edu.sg>
Date: 19 Jan 1999 00:35:20 GMT

It may be platform independent only if you distribute source as well. You
don't always want to distribute source. That being the case, the only
thing you can distribue is compiled object code. So to make that object
code platform independent, you wll need a JVM on each target platform to
run your Java bytecode. Your suggestion to compile to native machine code
actually exists for some products on at least the x86 platform.

Note that if you can distribute source, then the platform-independent
feature of Java can in fact be compared to C. C is supposed to be
platform-independent too, even though it isn't completely successful in
achieving that aim (well at least there is the ANSI C standard, the POSIX
standard...).
From: "InSaNe" <limdauhe@comp.nus.edu.sg>
Date: Wed, 20 Jan 1999 00:10:06 +0800

i get what you are trying to say. however there is no need for the
programmer to release the source. he can always compile it first right? he
can use the windows java compiler to compile the source to machinecode for
use on windows platform and do it likewise for the mac platform using the
mac java compiler. then he only need to destribute all these different
version so that users can download the appropriate version for their own
platform. isn't this method better since the program is in machinecode
already?
From: Supernova<ngqweeli@comp.nus.edu.sg>
Date: 20 Jan 1999 07:06:26 GMT

> i get what you are trying to say. however there is no need for the
> programmer to release the source. he can always compile it first right? he
> can use the windows java compiler to compile the source to machinecode for
> use on windows platform and do it likewise for the mac platform using the
> mac java compiler. then he only need to destribute all these different
> version so that users can download the appropriate version for their own
> platform. isn't this method better since the program is in machinecode
> already?

Wouldn't this be very tedious?
Suppose you want to put up an applet on a webpage. Are you going to compile
different versions of the same applet, each for a specific machine/platform?
Even if you are will to go through this process, how can you be sure you have
included all possible platforms? Perhaps, users of those platforms you
unintentionally missed out might feel discriminated.
From: "InSaNe" <limdauhe@comp.nus.edu.sg>
Date: Wed, 20 Jan 1999 21:23:55 +0800

>Wouldn't this be very tedious?
>Suppose you want to put up an applet on a webpage. Are you going to compile
>different versions of the same applet, each for a specific machine/platform?
>Even if you are will to go through this process, how can you be sure you have
>included all possible platforms? Perhaps, users of those platforms you
>unintentionally missed out might feel discriminated.

that is true for applets. but what i have in mind is for applications
instead of applets. because i feel most programmers do not write
applications using java due to the slow speed of the interpreter. so if sun
were to release different compiler for different platforms, then i feel that
a lot of programmers would want to switch over to java. however i feel that
there should be a flaw in my suggestion because if it could be done, sun
should already have done so long ago.
From: Leong Mun Wai <leongmun@comp.nus.edu.sg>
Date: 20 Jan 1999 13:37:56 GMT

Sun's philosophy for Java is to 'write once, run anywhere'. Compiling a
Java program into native machine code would break it. That's why they
haven't done such a thing.
From: Lai Zit Seng <laizs@comp.nus.edu.sg>
Date: 20 Jan 1999 14:53:34 GMT

It will be quite a challenge for Sun to release a different compiler for
every imaginable platform. At present, they only manage to provide JDK/JVM
for Solaris SPARC/x86 and Windows (okay, Linux soon) on their own. One
could argue that Sun could have sold Java purely as a language and get
every vendor/computer manufacturer to create "perfectly standardized"
compilers much the same way they currently try to get everything produce
compatible JVMs. A lot more could be argued (both ways) about this, but
there are other issues to look at too...

Application developers have to go compile their code on every imaginable
platform. System administrators supporting an environment with diverse
computing platforms would have to concern themselves with
platform-specific versions of binaries they obtain and install. All these
seem like a lot of work. 

So it seems like Sun's model works best overall. Performance is the only
major problem. But Sun expected to capitalize on improved JVMs (eg, using
JIT), faster processors, and processors that execute Java bytecode
natively.
From: Derek Kiong Beng Kee <dkiong@comp.nus.edu.sg>
Date: 21 Jan 1999 14:37:43 GMT

There are some points which I did not want to add
to complicate matters.
Many C expressions can be converted almost 1 to 1
to assembly.
However, there are Java expressions that cannot
and involve a higher overhead anyway.

From: YYT <yeoyeete@comp.nus.edu.sg>
Subject: TIME IN JAVA
Date: 18 Jan 1999 16:08:16 GMT

I know that one can get the system's time in milli-seconds by the
System.currentTimeMillis() method, but can we get the system's time in
10^-6 seconds???platform suitability. Jus my two $
From: StarLght <limchon2@comp.nus.edu.sg>
Date: 19 Jan 1999 00:30:30 GMT

Possible to get timing in such precision? The moment you invoke a call,
how many 10^-6 seconds have passed?

From: Mo Lin <molin@comp.nus.edu.sg>
Subject: java swing problem
Date: 26 Jan 1999 07:23:38 GMT

hi, anyone knows how to run java swing component on web page?
thanks in advance!
From: Lee Yeow Leong <leeyeowl@comp.nus.edu.sg>
Date: Tue, 26 Jan 1999 20:12:03 +0800

U must have plugin 1.2 installed.
http://java.sun.com/products/plugin/

From: "sinister" <limboon3@comp.nus.edu.sg>
Subject: [java] (URGENT) deprecation problem
Date: Wed, 27 Jan 1999 17:52:56 +0800

receive the following message when trying to compile a problem:
"Note: program.java uses a deprecated API. Recompile with "-deprecation"
fo."

So i compiled the program again with "-deprecation", this message appeared:
"program.java:68: Note: The constructor
java.io.StreamTokenizer(java.io.Inpu.
StreamTokenizer thing = new StreamTokenizer(input);
^
Note: interpreter.java uses a deprecated API. Please consult the
documentation.
2 warnings"
From: <khooyong@comp.nus.edu.sg>
Subject: Re: [java] (URGENT) deprecation problem
Date: 27 Jan 1999 11:20:21 GMT

change your code to the following

Reader r = new BufferedReader(new InputStreamReader(input));
StreamTokenizer thing = new StreamTokenizer(r);

From: Yeap Jack Ping <yeapjack@comp.nus.edu.sg>
Subject: [Java] readDouble
Date: 29 Jan 1999 00:39:09 GMT

I did a readDouble to read in a double value (2.5) from the keyboard, but 
instead of 2.5, I got something like 8.63...E.. long number. Then I tried
(Double.valueOf(dis.readLine())).doubleValue() , I got 2.5. Does anyone 
know why is this so?
From: Tong Wing <woontong@comp.nus.edu.sg>
Date: 1 Feb 1999 04:09:51 GMT

Yeap Jack Ping <yeapjack@iscs.nus.edu.sg> wrote:
: Yup, I did a DataInputStream dis = new DataInputStream(System.in);
: double x = dis.readDouble();

what you're doing is reading ascii characters from standard in
and interpreting them as ieee double. you should really be
using Double.parseDouble(dis).
From: LockSmith <woontong@comp.nus.edu.sg>
Date: 1 Feb 1999 15:25:14 GMT

Lee Yeow Leong <leeyeowl@comp.nus.edu.sg> wrote:
: Derek Kiong Beng Kee <dkiong@comp.nus.edu.sg> wrote:
:> Yeap Jack Ping <yeapjack@comp.nus.edu.sg> wrote:
:> : I did a readDouble to read in a double value (2.5) from the keyboard, but 
:> : instead of 2.5, I got something like 8.63...E.. long number. Then I tried
:> : (Double.valueOf(dis.readLine())).doubleValue() , I got 2.5. Does anyone 
:> : know why is this so?
:> readDouble does not concern ASCII bytes
: Sir, in that case where does the problem lies? Does it got something to do
: with the end of stream?

let's look at the - somewhat - C equivalent of the code:

Java: Double d = dis.readDouble();
C: fread(&d, sizeof(double), 1, stdin);

Java: Double.valueOf(dis.readLine()).doubleValue();
C: fgets(line, SIZE, stdin);
sscanf(line, "%lf", &d);

From: oOh_CHiLD <ohyeokch@comp.nus.edu.sg>
Subject: [java] string operations
Date: 2 Feb 1999 14:31:50 GMT

suppose I have this string "this \n\n apple \n\n king \n\n"
Notice that the above words in the string are separated by \n\n
Is there any method whereby I can extract out (as indicated by ^^^) 
"this \n\n apple \n\n king \n\n". TIA! :)
^^^^^ ^^^^^^^ ^^^^^^
From: StreetHawk <karrisid@comp.nus.edu.sg>
Date: 2 Feb 1999 15:42:48 GMT

tokenize setting '/n/n' as delimiter??
From: Lee Yeow Leong <leeyeowl@comp.nus.edu.sg>
Date: Wed, 03 Feb 1999 01:11:26 +0800

Leong Mun Wai wrote:
> Lee Yeow Leong <leeyeowl@comp.nus.edu.sg> wrote:
> :> tokenize setting '/n/n' as delimiter??
> 
> : 1 '/n' should be enough.
> 
> Actually if you use the StringTokenizer(String) constructor, you don't
> even need to specify any delimiters as '\n' is one of the default delims.
> 

Your answer to his question would be incorrect if u do that. 
Dun forget that space is also one of the default delims. :)

From: Jess <quekhuin@comp.nus.edu.sg>
Subject: [Java] Graph package?
Date: 3 Feb 1999 02:01:16 GMT

Is there a package that I can use to plot pie charts, bar charts, line
graphs, etc.?
From: Ah Lim <limweeli@comp.nus.edu.sg>
Date: 3 Feb 1999 11:45:53 GMT

Tea Set Widgets .... check http://www.inetsoftcorp.com/

From: valk <ngkaboon@comp.nus.edu.sg>
Subject: [Java] IPC?
Date: 4 Feb 1999 01:35:20 GMT

Does Java support IPC like pipes (not communicating only with Java prog
but with any programming lang in general?)?

Other than Sockets, what are common IPCc in Java that talk with other 
processes.

Path: !sund.iscs.nus.sg!not-for-mail
From: DoCoMo <khoohuit@comp.nus.edu.sg>
Newsgroups: iscs.comp.programming
Subject: Re: [JAVA] How to change the proxy of the browser
Date: 4 Feb 1999 02:42:08 GMT
Organization: NTT
Lines: 4
Sender: DoCoMo <khoohuit@decunx.iscs.nus.sg>
Message-ID: <79b1e0$o47$1@sund.iscs.nus.sg>
References: <77uhp5$ch4$1@sund.iscs.nus.sg> <7899he$g0t$3@sund.iscs.nus.sg> <78blda$rld$1@sund.iscs.nus.sg>

NNTP-Posting-Host: decunx-m.comp.nus.edu.sg
NNTP-Posting-User: khoohuit
User-Agent: tin/pre-1.4-981225 ("Volcane") (UNIX) (OSF1/V4.0 (alpha))
Xref: iscs.comp.programming:802

System.getProperties().put("proxySet", true);
System.getProperties().put("proxyHost", "proxy.nus.edu.sg");
System.getProperties().put("proxyPort", "8080");