title: Java URL: Unknown Protocol "C"
body: <p>I know there are <em>similar</em> questions to this one on SO (like <a href="https://stackoverflow.com/questions/7243550/unknown-protocol-c-jdom-a-saxbuilder">this</a> one), however, after reading through the list of "Questions with similar titles", I still feel strongly that this is unique.</p>
  
  <p>I am working with the <a href="http://itextpdf.com/" rel="noreferrer">iText</a> library to generate PDFs from inside a Swing application. iText's <code>Jpeg</code> class requires a <a href="http://docs.oracle.com/javase/6/docs/api/java/net/URL.html" rel="noreferrer"><code>URL</code></a> in its constructor to locate an image/jpg that you want to add to the PDF file.</p>
  
  <p>When I set this <code>URL</code> to the absolute file path of my JPG file, I get a <code>MalformedURLException</code> claiming <strong>unknown protocol: c</strong> ("c" being the <code>C:\</code> drive on my local disk).</p>
  
  <p>Is there any hack/circumvention to this, or do I <em>have</em> to host this JPG somewhere and have the <code>URL</code> find it over the net?  Here is the code that is failing:</p>
  
  <pre><code>try {
      String imageUrl = "C:\Users\MyUser\image.jpg";
      Jpeg image = new Jpeg(new URL(imageUrl));
  } catch(Exception exc) {
      System.out.println(exc.getMessage());
  }
  </code></pre>
  
  <p><strong>Please note:</strong> The <code>URL</code> does properly escape the string (thus "\" are converted to "\ \", etc.).</p>
  
  <p>Thanks in advance!</p>