• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.nio

 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can i use this package for my assignment?

Thanks,
 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does it say in your assignment about it, or networking?
 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ???
 
Author
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Weerawit

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

Regards, Andrew
 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks

 
Eben Hewitt
Author
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic