This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UnknownHostException: C

 
Akash Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Akash Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Akash Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic