• Post Reply Bookmark Topic Watch Topic
  • New Topic

I suddenly can't make instances of 'File'  RSS feed

 
Chaz Andrews
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I swear that yesterady this worked, then today... nothing.
Every time I try compileing it I get
Copy.java:5: cannot find symbol
symbol : constructor File(java.lang.String)
location: class File
File inputFile = new File("listofregions.txt");
I've tried reinstalling java, checked classpath, what have I done wrong?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
552
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chaz,
That line should certainly compile. What command are you using to compile?
> javac Copy.java
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have most likely created your own class named "File"; either File.java or File.class is on your classpath, someplace. Find it, delete it, don't do that again!
 
Chaz Andrews
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
You have most likely created your own class named "File"; either File.java or File.class is on your classpath, someplace. Find it, delete it, don't do that again!


lol, thats it. Cheers guys.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, that wouldn't have happened if you had used a fully qualified import:

import java.io.File;

Another reason not to use wildcard imports...
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!