Malformedurlexception unknown protocol socket что это

Обновлено: 17.05.2024

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.


34.5k 37 37 gold badges 147 147 silver badges 168 168 bronze badges The question is which "browser setting" is used on Linux as default? Good point keiki. Running linux here. I had proxy set up in Firefox but was launching the JNLP app from chrome and this error was a mystery to me. If you are in Linux Run command ControlPanel and Go to General > Network Settings.. > Direct Connection

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:

Summary of Exception

Details of Exception


34.5k 37 37 gold badges 147 147 silver badges 168 168 bronze badges What is the (presumably malformed) URL? Post code, error messages and stack trace; not pictures. In my case I just had to disable the proxy on. Firefox (as it is my primary browser)!

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.


34.5k 37 37 gold badges 147 147 silver badges 168 168 bronze badges The question is which "browser setting" is used on Linux as default? Good point keiki. Running linux here. I had proxy set up in Firefox but was launching the JNLP app from chrome and this error was a mystery to me. If you are in Linux Run command ControlPanel and Go to General > Network Settings.. > Direct Connection

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:

Summary of Exception

Details of Exception


34.5k 37 37 gold badges 147 147 silver badges 168 168 bronze badges What is the (presumably malformed) URL? Post code, error messages and stack trace; not pictures. In my case I just had to disable the proxy on. Firefox (as it is my primary browser)!

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 означает, что потенциально не все содержимое должно быть загружено в память одновременно, что может быть отличной идеей!

Читайте также: