It's not a secret anymore!*
The moose likes Beginning Java and the fly likes Can't compile my class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic
Author

Can't compile my class

Mathias Nilsson
Ranch Hand

Joined: Oct 13, 2003
Posts: 107
Hi ranchers!
I have I problem that hasn't been a problem before. I got it after formatting my Harddrive.
I have compiled a test file like this.
Blocker.java

When I try to use it in my FBMain file I get a compile error.

When I remove the import Blocker; statement it works. I can't use the Blocker class in my FBMain class. Here is my PATH and classpath in Windows 2000

My files are located in F:\Edge Soft\Work\java\
Please help!


SCJP2 , MCP( 70-229 ) , Preparing For SCWDC
Mathias Nilsson
Ranch Hand

Joined: Oct 13, 2003
Posts: 107
Ehhh...
I created a new directory "test" under my java catalouge. I put package test in my Blocker file. I used import test.Blocker; instead and it worked??? Why? Anyone?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

"import ClassName" is illegal as per the JLS: you can't import names out of the default package. Older JDK compilers allowed this anyway, but now the rule is being enforced. Presumably when you reformatted, you upgraded your JDK version.


[Jess in Action][AskingGoodQuestions]
Mathias Nilsson
Ranch Hand

Joined: Oct 13, 2003
Posts: 107
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't compile my class