Malformedurlexception unknown protocol socket что это
I' m writing a class to run xjc in java. my code goes as follows:
however I get the following error when I run this:
Can anyone help with this please?
41.6k 17 17 gold badges 75 75 silver badges 101 101 bronze badges 131 1 1 gold badge 1 1 silver badge 5 5 bronze badges Have you tried sc.parseSchema(new InputSource("C:\\Users\\Simran\\Desktop\\books.xsd")); As I suggested before ?3 Answers 3
Try append "file://" to the beginning of your file path. But as Bozho proposed, you don't need an URL here.
41.6k 17 17 gold badges 75 75 silver badges 101 101 bronze badges can anyone give me some link for using xjc through API calls?This is not a valid URL. It can be made valid by prepending file:// as protocol.
But you don't need a URL at all. You can pass a Reader (as well as an InputStream ) to the InputSource constructor. So for example:
Моя программа пытается проанализировать XML-строку, используя:
Строка XML содержит:
Любые предложения о том, что вызывает эту ошибку?
Обратите внимание: если вы читаете XML файл из файла, вы можете напрямую передать объект File DocumentBuilder.parse() .
В качестве побочного примечания, это шаблон, с которым вы столкнетесь много на Java. Обычно большинство API работают с Streams больше, чем с помощью Strings. Использование Streams означает, что потенциально не все содержимое должно быть загружено в память одновременно, что может быть отличной идеей!
4 Answers 4
Go to Control Panel of Windows and do the followings:
Click Java -> Click "Network Settings. " button under General tab -> Select Direct connection radio -> Click OK
That's it. Exception could be removed.
This message comes from the use of a proxy server which is not fully set in Internet options (in Internet Explorer).
When a proxy server is set manually, but with the option "use this server for all protocols", Internet Explorer does not fill the "Socks" protocol field with it.
Direct connection works, because you bypass this proxy configuration set in IE. But another way to fix this is to uncheck "use this server for all protocols", and instead paste it in the socks field as well.
It should solve the issue without having to bypass the proxy for all Java programs.
However, this is assuming that your proxy server knows what to do with this protocol, and how to direct it to the correct place. If it doesn't, then you are probably better off trying direct connection.
I have Studio.jnlp file. I tried to open it by double-click. But I found the error as below:
4 Answers 4
Go to Control Panel of Windows and do the followings:
Click Java -> Click "Network Settings. " button under General tab -> Select Direct connection radio -> Click OK
That's it. Exception could be removed.
This message comes from the use of a proxy server which is not fully set in Internet options (in Internet Explorer).
When a proxy server is set manually, but with the option "use this server for all protocols", Internet Explorer does not fill the "Socks" protocol field with it.
Direct connection works, because you bypass this proxy configuration set in IE. But another way to fix this is to uncheck "use this server for all protocols", and instead paste it in the socks field as well.
It should solve the issue without having to bypass the proxy for all Java programs.
However, this is assuming that your proxy server knows what to do with this protocol, and how to direct it to the correct place. If it doesn't, then you are probably better off trying direct connection.
Security Exception: MalformedURLException: unknown protocol: socket during opening JNLP file
I have Studio.jnlp file. I tried to open it by double-click. But I found the error as below:
3 Answers 3
Try append "file://" to the beginning of your file path. But as Bozho proposed, you don't need an URL here.
41.6k 17 17 gold badges 75 75 silver badges 101 101 bronze badges can anyone give me some link for using xjc through API calls?This is not a valid URL. It can be made valid by prepending file:// as protocol.
But you don't need a URL at all. You can pass a Reader (as well as an InputStream ) to the InputSource constructor. So for example:
Моя программа пытается проанализировать XML-строку, используя:
Строка XML содержит:
Любые предложения о том, что вызывает эту ошибку?
Обратите внимание: если вы читаете XML файл из файла, вы можете напрямую передать объект File DocumentBuilder.parse() .
В качестве побочного примечания, это шаблон, с которым вы столкнетесь много на Java. Обычно большинство API работают с Streams больше, чем с помощью Strings. Использование Streams означает, что потенциально не все содержимое должно быть загружено в память одновременно, что может быть отличной идеей!
Читайте также: