JApplet URL load ImageIcon

  • Thread starter courtney.schatzman
  • Start date
C

courtney.schatzman

Hey there, I am new to Java/swing. I have a question on URL exceptions.

on compilation error msg:

ImageApp.java:38: cannot find symbol
symbol : class URL
location: class ImageApp
icon = new ImageIcon(new URL("http://aeolus/work/screen.gif"));

I have the appropriate imports e.i. java.net.URL. I am compiling with
'-source 1.4' flag.
The ref. matterial I am using is from java sun SE 1.4.2. I am out of
ideas as how to
resolve this exception. Could someone give me an indication on how to
solve this?
 
A

Andrew Thompson

on compilation error msg:

ImageApp.java:38: cannot find symbol
symbol : class URL
location: class ImageApp
icon = new ImageIcon(new URL("http://aeolus/work/screen.gif"));

Does this compile for you?

<sscce>
class URLImport {
public static void main(String[] args) {
java.net.URL url;
}
}
</sscce>

Andrew T.
 
C

courtney.schatzman

Yeah that compiles.
Could I then you use this class in a classLoader to load image?

Thanks,
cschatz


Andrew said:
on compilation error msg:

ImageApp.java:38: cannot find symbol
symbol : class URL
location: class ImageApp
icon = new ImageIcon(new URL("http://aeolus/work/screen.gif"));

Does this compile for you?

<sscce>
class URLImport {
public static void main(String[] args) {
java.net.URL url;
}
}
</sscce>

Andrew T.
 
A

Andrew Thompson

(e-mail address removed) wrote:

Pleasre refrain from top-posting. See further text 'in-line'.
Andrew said:
on compilation error msg:

ImageApp.java:38: cannot find symbol
symbol : class URL
.....
Does this compile for you?

<sscce>
class URLImport {
public static void main(String[] args) {
java.net.URL url;
}
}
</sscce>
...
Yeah that compiles.
Could I then you use this class in a classLoader to load image?

This code is simply a test. It proves that java.net.URL
is available on the classpath of the default VM that your
system is using to compile. It also contradicts the earliest
statements you made.

'....on compilation error msg:
....cannot find symbol
symbol : class URL
.......
I have the appropriate imports e.i. java.net.URL'

If the code you originally were referring to, had the
import (or a fully qualified class name, as I did in the
example) - it should compile without the 'cannot find symbol'
message.

If you cannot fix it from the hints so far, I suggest you
produce an SSCCE* of code that will not compile, it
should be less than 30 lines to express a problem like
this.

I'll give you odds of 40% that you will be able to spot the
mistake in the process of making an SSCCE. If not, post
the SSCCE here and answers should follow quickly.

* <http://www.physci.org/codes/sscce/>

HTH

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top