27.04.2013 Views

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Miscellaneous I<br />

Volume Serial Number is 07CF-0B17<br />

Directory of C:\<br />

JDK12~1 2 03-19-00 1:57a jdk1.2.2<br />

JDK13~1 0 12-21-00 1:42a jdk1.3.0<br />

JDK11~1 8 06-16-00 2:29p jdk1.1.8<br />

0 file(s) 0 bytes<br />

3 dir(s) 16,252.02 MB free<br />

c:\>PATH<br />

PATH=c:\java\bin;c:\tools;c:\windows;c:\windows\command<br />

c:\>ren jdk1.2.2 java<br />

If I wanted to switch to JDK 1.3.0, I simply do:<br />

c:\>ren java jdk1.2.2<br />

c:\>ren jdk1.3.0 java<br />

and voila! new JVM. The drawback here is you need to know what the current one is,<br />

but that's simple using java -version or by process of elimination.<br />

--<br />

Joseph A. Millar<br />

Q: I would like to know if it could be considered as dangerous to change directly<br />

the content of a bytecode.<br />

Perhaps you'll think the question is strange... In my case, I'm just trying to replace the<br />

content of a known string by another string of the same length.<br />

I 've already tried and it seems to work properly, but I'm not sure that it could be OK<br />

with different (all) JVM or for example, if the content of the bytecode could controlled<br />

by a checksum or something.<br />

on JVM there's nothing about these kind of control.<br />

Answer: Depends on your definition of "dangerous." If you mean "error-prone", then I<br />

would answer with a definite yes, especially if you are modifying the code itself... you<br />

need to be aware of all the jump targets so you can update them as necessary, and<br />

understand enough about the verifier that you can write provably safe code;<br />

otherwise a verifier will reject the class file.<br />

However, a properly written resulting class file is perfectly valid and portable; that's<br />

the meaning of <strong>Java</strong>'s much-hyped "binary compatibility".<br />

There are also no checksums to worry about.<br />

--<br />

Chris Smith<br />

Q: what is the difference between "C:\\" and "C:\\." ?<br />

In the following codes. can anyone explain this ?<br />

File dir = new File("C:\\" );<br />

String [ ] files = dir .list();<br />

File dir = new File("C:\\." );<br />

String[] files = dir.list();<br />

Answer: "." is used to refer to the current directory. For example, using the change<br />

file:///F|/350_t/350_tips/miscellaneous-I.htm (9 of 11) [2002-02-27 21:18:44]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!