Joe*_*ips 9 java packages compiler-errors javac
我没有设置%CLASSPATH%.据我所知,这应该不是问题,因为Javac将假定当前目录的类路径.
正如您在下面看到的,Case即使它位于同一个目录中,javac仍无法找到我的类.有关为什么会发生这种情况的任何想法?当我使用Eclipse时,此代码工作正常.
C:\Documents and Settings\joep\My Documents\GCJ\src\codejam2011\Round0\D>dir /B
Case.class
Case.java
EntryPoint.java
C:\Documents and Settings\joep\My Documents\GCJ\src\codejam2011\Round0\D>javac EntryPoint.java
EntryPoint.java:16: cannot find symbol
symbol : class Case
location: class codejam2011.Round0.D.EntryPoint
ArrayList<Case> cases = new ArrayList<Case>();
^
EntryPoint.java:16: cannot find symbol
symbol : class Case
location: class codejam2011.Round0.D.EntryPoint
ArrayList<Case> cases = new ArrayList<Case>();
^
EntryPoint.java:24: cannot find symbol
symbol : class Case
location: class codejam2011.Round0.D.EntryPoint
cases.add(new Case(new Integer(count), line));
^
3 errors
C:\Documents and Settings\joep\My Documents\GCJ\src\codejam2011\Round0\D>
Run Code Online (Sandbox Code Playgroud)
更新1:
尝试从我的包根(src)编译后,我得到一个新的错误(即使删除Case.class文件后)
C:\Documents and Settings\joep\My Documents\GCJ\src>javac -cp . codejam2011/Round0/D/EntryPoint.java
codejam2011\Round0\D\EntryPoint.java:16: cannot access codejam2011.Round0.D.Case
bad class file: .\codejam2011\Round0\D\Case.java
file does not contain class codejam2011.Round0.D.Case
Please remove or make sure it appears in the correct subdirectory of the classpath.
ArrayList<Case> cases = new ArrayList<Case>();
^
1 error
C:\Documents and Settings\joep\My Documents\GCJ\src>
Run Code Online (Sandbox Code Playgroud)
更新2: 它似乎从另一个包中获取Case.java文件.
C:\Documents and Settings\joep\My Documents\GCJ\src>javac -d ../classes codejam2011\Round0\D\*.java
.\codejam2011\Round0\D\Case.java:4: duplicate class: codejam2011.Round0.C.Case
public class Case
^
codejam2011\Round0\D\EntryPoint.java:16: cannot access codejam2011.Round0.D.Case
bad class file: .\codejam2011\Round0\D\Case.java
file does not contain class codejam2011.Round0.D.Case
Please remove or make sure it appears in the correct subdirectory of the classpath.
ArrayList<Case> cases = new ArrayList<Case>();
^
2 errors
C:\Documents and Settings\joep\My Documents\GCJ\src>
Run Code Online (Sandbox Code Playgroud)
Bal*_*usC 19
您需要从包根目录进行编译,而不是从包内部进行编译.
所以,cd到那个src文件夹并编译.
javac -cp . codejam2011/Round0/D/EntryPoint.java
Run Code Online (Sandbox Code Playgroud)
更新:根据您的新问题,您需要以Case.java相同的方式重新编译.它显然是以相同的错误方式编译的(从包内部).
| 归档时间: |
|
| 查看次数: |
38399 次 |
| 最近记录: |