aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes UnknownHostException: C Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "UnknownHostException: C" Watch "UnknownHostException: C" New topic
Author

UnknownHostException: C

Akash Singh
Ranch Hand

Joined: Aug 21, 2003
Posts: 80
I am getting "java.net.UnknownHostException: C", when invoking user help doc on Windows XP. Same code works fine on Linux and Windows 2000.
Here is my code:


Could any help me on this. Why am I getting this error on Windows XP.
Regards.
Akash
Denis Spirin
Ranch Hand

Joined: Mar 22, 2004
Posts: 72
private static final String DOCUMENTATION_URL = "file://"
+ System.getProperty("user.dir")
+ System.getProperty("file.separator")
+ "userDocs"
+ System.getProperty("file.separator")
+ "ui"
+ System.getProperty("file.separator")
+ "LogOnUserDoc.htm";

I guess you get something like :
file://somePath\userDocs\ui\LogOnUserDoc.htm
Is it correct URL?
Regards
[ April 10, 2004: Message edited by: Denis Spirin ]

Regards<br /> <br />Ph.D.<br />SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD 2
Akash Singh
Ranch Hand

Joined: Aug 21, 2003
Posts: 80
Thanks Denis for your reply.
I am not able to resolve this issue. This problem only comes when I test
my FBN Assignment on XP. On Linux and Windows 2000, I get user help doc, that is an HTML page.

DOCUMENTATION_URL resolved as :
file://C:\scjd\userDocs\ui\LogOnUserDoc.htm
And my file is in this location. In fact with this URL(file://C:\scjd\userDocs\ui\LogOnUserDoc.htm) , IE browser displays the LogOnUserDoc.htm. I do'nt why it is not resolving this URL from the code on XP.
Below is the stack trace of the exception.
java.net.UnknownHostException: C
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.NetworkClient.openServer(Unknown Source)
at sun.net.ftp.FtpClient.openServer(Unknown Source)
at sun.net.ftp.FtpClient.<init>(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Sour
ce)
at javax.swing.JEditorPane.getStream(Unknown Source)
at javax.swing.JEditorPane.setPage(Unknown Source)
at javax.swing.JEditorPane.setPage(Unknown Source)
at suncertify.ui.ConnectionUI$DocumentListener.actionPerformed(Connectio
nUI.java:794)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow
n Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease
d(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Regards,
Akash
Denis Spirin
Ranch Hand

Joined: Mar 22, 2004
Posts: 72
Hi,
I think you should try using this URL:
file://C:/scjd/userDocs/ui/LogOnUserDoc.htm
I dont work on Windows so I m not sure. Anyway, in Java both URL and URI are not platform dependent, i.e. there s no need to use "file.separator" property. The same relates to RMI (which uses URL).
Hope it helps,
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Originally posted by Akash Singh:
DOCUMENTATION_URL resolved as :
file://C:\scjd\userDocs\ui\LogOnUserDoc.htm
java.net.UnknownHostException: C
at java.net.PlainSocketImpl.connect(Unknown Source)

Regards,
Akash

I'm not a guru, but it looks to me like "C:" is being treated as a host name, as in HostName ort. Try dropping the "C:" and just use "\scjd\..." and see what happens.
Burk


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Akash Singh
Ranch Hand

Joined: Aug 21, 2003
Posts: 80
Thanks for reply Denis and Berk.
This is solved.
Actually is has to be :
file:///C:\scjd\userDocs\ui\LogOnUserDoc.htm

As per the URL syntax:
protocol://hostname/file
Since hostname part in blank in this case:
it will be "file:///file"
that is "file:///C:\scjd\userDocs\ui\LogOnUserDoc.htm".
But surprisingly, windows 2000 and Linux did not give any error with url "file://C:\scjd\userDocs\ui\LogOnUserDoc.htm". However Windowx XP is giving UnknowHostException for this url.
Regards,
Akask
 
Don't get me started about those stupid light bulbs.
 
subject: UnknownHostException: C