![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |
| |||
| ditto: You can set a package for MyClass (recommended). Or you can include your path on your command line for the compiler (in which case comment out your import statement as Foxy points out): # mostly works: $ javac -cp . Applet19.java I say mostly works because when I compiled it, you seem to be using deprecated code. A tweak of the command line reveals that: $ javac -cp . -Xlint:deprecation Applet19.java Applet19.java:32: warning: [deprecation] action(java.awt.Event,java.lang.Object) in java.awt.Component has been deprecated public boolean action(Event event, Object arg) ^ 1 warning Here is any more info just in case my deprecated comment is out of date: $ java -version java version "1.5.0_02" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09) Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing) |
| |||
| It seems you are using the default package. When using the default package, or whenever the class that you want to use is in the same package as the other class, then you shouldn't import it. Hence, simply remove the import MyClass; statement. BTW, in java world, the use of the default package is discouraged. It will cause some troubles; for example, if you want to use some classes located at the default package from another class inside another package, you won't be able to import those classes from the default package. Enjoy! EDIT I forgot to tell you that the reason of the error by the compiler, is that it expected an inner class. For example, if the MyClass has an inner class or something, then you will have to write import MyClass.MyInnerClass; Another reason could be from the fact that you cannot import default package classes, the complier thought MyClass to be a package. Thanks. |
![]() |
| Thread Tools | |
| Display Modes | |
| |