File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes java.nio Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "java.nio" Watch "java.nio" New topic
Author

java.nio

Weerawit Maneepongsawat
Ranch Hand

Joined: Apr 11, 2002
Posts: 203
Can i use this package for my assignment?

Thanks,


Weerawit<br />SCJP 1.4, SCWCD 1.2, SCWCD 1.4, SCBCD 1.3, SCBCD 5.0, SCMAD 1.0, SCJA 1.0, SCDJWS, SCJD, SCEA, SCDJWS 1.5
Robert Konigsberg
Ranch Hand

Joined: Jun 23, 2004
Posts: 172
What does it say in your assignment about it, or networking?


SCJP 1.4 (91%)<br />SCJD 1.4 (376/400, 94%)
Weerawit Maneepongsawat
Ranch Hand

Joined: Apr 11, 2002
Posts: 203
Originally posted by Robert Konigsberg:
What does it say in your assignment about it, or networking?


http://suned.sun.com/US/catalog/courses/CX-310-252A.html


The following APIs and facilities may not be used:

Enterprise JavaBeans
Servlets, JSP technology, or any other web-oriented APIs
NIO, the New IO facilities
Java DataBase Connectivity (JDBC) and SQL
Java IDL API and CORBA
Third party software libraries or tools (such as browsers)


Just wanna make sure, but why i can't use NIO instade of java.io ???
Eben Hewitt
Author
Ranch Hand

Joined: Apr 16, 2004
Posts: 36
What assignment do you have? I did Bodgitt and Scarper, and I used NIO. While I was aware of this URL you give, that was _not_ in my instructions.html file.

I did mention, I think, that I had seen that link and that it was confusing, but in the end decided that my instructions.html document had to be the authority, it being more specific.

In inheritance, the most specific matching method gets called. So that was my reasoning.

I would say, unless your instructions document specifically forbids NIO (which I believe some do), you can use it.


Eben Hewitt. SCJP, SCWCD, SCJD, SCJWSD for JEE 5, TOGAF 8 Certified Architect, author of Java SOA Cookbook (O'Reilly, 2009) and contributor to 97 Things Every Software Architect Should Know
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by Eben Hewitt:
What assignment do you have? I did Bodgitt and Scarper, and I used NIO. While I was aware of this URL you give, that was _not_ in my instructions.html file.

I did mention, I think, that I had seen that link and that it was confusing, but in the end decided that my instructions.html document had to be the authority, it being more specific.

In inheritance, the most specific matching method gets called. So that was my reasoning.

I would say, unless your instructions document specifically forbids NIO (which I believe some do), you can use it.


Although not certified in anything, I am one of the Sun Forum's more regular NIO and Socket contributers. I understand this non-blocking stuff and have used it a great deal for a long time in many languages (IBM360ASM, C, C++, Java, VB, APL). If I had a choice on an assignment to use something else like multithreaded stream oriented socket i/o or RMI, I'd jump at the chance. Java NIO is bleeding edge and flakey. In most other languages it old hat and reliable but difficult.

When in doubt use the tried and true methods. I believe the SCJD project is not marked on the basis of cleverness, but rather on straight forward understandable maintainable results.

If it doesn't explicitly say use NIO, DON'T, you are asking for trouble. Save that for the 1.5 project.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11278
    
  59

Hi Weerawit

Take a look at the thread "We are allowed to use NIO".

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Weerawit Maneepongsawat
Ranch Hand

Joined: Apr 11, 2002
Posts: 203
Thanks

Eben Hewitt
Author
Ranch Hand

Joined: Apr 16, 2004
Posts: 36
Hi PK

The SCJD does not make you choose between RMI and NIO, as I think you suggest. The choice is between RMI and net sockets.

There are a few reasons that it makes sense to read the entire SCJD db file into a byte buffer given the character encoding--_if_ the test taker is implementing the database in a way that calls for reading in all the records. Many people don't do that, and do quite well on the exam.

I think NIO is fast and reliable. If people are interested working with areas of Java technology that might be new to them, then the SCJD offers an excellent opporunity to do that. Maybe people don't have occasion to learn NIO at their jobs; they can do so here. I think this sort of use of the cert exams is better than just getting through the thing as quickly as possible just to get the paper.

So I have a couple of questions.

What's the part where NIO is "flakey"?

How is it "clever" to use a standard Java library in the exact way it is intended to be used, to do something standard like reading bytes from a file?

I believe the SCJD project is not marked on the basis of cleverness, but rather on straight forward understandable maintainable results.


That is true. However, I fail to see what is not maintainable or understandable about using a standard library in a standard way.

NIO was included, as you know, in SDK 1.4.0, which was released 2 years ago. Since you "have used it a great deal for a long time", how exactly is NIO "bleeding edge stuff"?

I am just asking, because that is a fairly common question in this forum it seems ("Can I use NIO?", "Is it a good idea?", etc.). It is good for test takers have an understanding of the advantages and disadvantages of why/how/when to employ something.

Perhaps you have more specific reasons why test takers should avoid it?

Thanks
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
Perhaps you have more specific reasons why test takers should avoid it?

I suspect it's because Sun isn't prepared to offer a standardized criteria by which to judge NIO submissions. Since we're scheduled to start creating a new version of the exam before the end of the year, that's probably where this will be addressed.

HTH,
M


Java Regular Expressions
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by Eben Hewitt:
Hi PK

The SCJD does not make you choose between RMI and NIO, as I think you suggest. The choice is between RMI and net sockets.


I understand that is the case, there was a period when NIO was permitted.


I think NIO is fast and reliable. If people are interested working with areas of Java technology that might be new to them, then the SCJD offers an excellent opporunity to do that. Maybe people don't have occasion to learn NIO at their jobs; they can do so here. I think this sort of use of the cert exams is better than just getting through the thing as quickly as possible just to get the paper.

I agree that NIO is fast and learning NIO is useful, that's why I've provided assistance to those trying to do so on the Sun forums. Doing it as part of a job or a certification is probably not the best choice of venue.


So I have a couple of questions.

What's the part where NIO is "flakey"?

take a look at Bug 4850373, this involves occasional spinning of selectors, its supposedly fixed in 1.4.2_05 and 1.5. It tends to only occur in actual use. It was first reported in April 2003 and the fixed version was released quite recently. Its caused a lot of difficulty. There are numerous other examples, this one is just the most egregious.

Another example, less serious, but very annoying. NIO doesn't work properly if you are using the Windows TCP/IP filtering option. This code

fails throwing "java.io.IOException: Unable to establish loopback connection" although stream based sockets work fine when this optionis enabled.


How is it "clever" to use a standard Java library in the exact way it is intended to be used, to do something standard like reading bytes from a file?


That is true. However, I fail to see what is not maintainable or understandable about using a standard library in a standard way.

NIO was included, as you know, in SDK 1.4.0, which was released 2 years ago. Since you "have used it a great deal for a long time", how exactly is NIO "bleeding edge stuff"?

Its very new compared to the stream based code. The bugs I mentioned above are sufficient to get it labeled "bleeding edge". I didn't actually say it was unmaintainable or not understandable, rather I said I believed understandable, maintainable code were the requirements of the project.

I am just asking, because that is a fairly common question in this forum it seems ("Can I use NIO?", "Is it a good idea?", etc.). It is good for test takers have an understanding of the advantages and disadvantages of why/how/when to employ something.

Perhaps you have more specific reasons why test takers should avoid it?

Thanks

Beyond bugs there are other issues. For example ObjectOutputStream doesn't have an equivalent, you'll need to roll that yourself, this makes NIO difficult if you need to transfer serialized objects. You could do it by using a ByteArrayOutputStream wrapped in an ObjectOutputStream, then make your ByteBuffer from that, or just serialize to XML or ASN.1.

I personally would love to use NIO if it was allowed on the project and I was taking the cert. But at present neither of those is the case. If I were new to network development and wanted to get certified quickly, which I believe is the case with most people doing these projects, I'd avoid NIO.

For some interesting reading on NIO problems, take a look at Taming the NIO Circus. I've also provided a NIO Client Example and a NIO Server Exampleto help those who are interested in getting into this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.nio