Guys, how can I correct the error above, my class name does have the extension.java开发者_StackOverflow社区. I am new to j2me and I need to do a location based application but I am struggling so hard...
Generally in Java, each .java file can contain at most one public top-level class, and the file has to have the same name as this class.
So a class called MyClass
must be stored in a file called MyClass.java
!
NB: Class names should start with a capital letter
Update: when using packages (the package
instruction at the beginning of the java file), the file must be stored in a directory structure identical to the package structure.
So if you have this file:
package com.something.test;
public class MyClass {}
it must be stored in {root}/com/something/test/MyClass.java
and compiled with
javac com.something.test.MyClass
relative from the directory {root}
In NetBeans 6.5, I fixed this problem by following the first paths on the left down to:
fileName > Source Packages > filename > Main.java
Right-click on Main.java, move the mouse over Refactor, then click Rename. Type the class name there (it IS case-sensitive) and select Refactor. This should solve the problem.
精彩评论