Reputation: 65
I was trying to do an ant build that compiled a java project source code when i ran into a problem i could not explain. First my ant target:
<target name="compile-companymanage" depends="compile-company">
<mkdir dir="${companymanagebin}"/>
<javac destdir="${companymanagebin}">
<src path="${companymanagesrc}" />
<classpath refid="companyManage.classpath"/>
</javac>
</target>
After running that i get the error:
[javac] project\src\com\company\manage\vo\InvoiceLineSupplierVM.java:31: error: class InvoiceLineSupplierVM is public, should be declared in a file named InvoiceLineSupplierVM.java
[javac] public class InvoiceLineSupplierVM
[javac] ^
[javac] 1 error
We have tried it with different projects and they compile just fine. Hope someone can help me.
We have tried renaming the file and class with the same name.
Upvotes: 1
Views: 70
Reputation: 52195
Adding the answer for completeness sake and to simplify the lives of other people which will encounter this error in the future.
Most likely you have a non-printable character in one of your names, either your class name or your file name. This will cause a mismatch between what the compiler has or expects.
To solve this problem, what one usually does is to rename the files and classes involved. It is important that when renaming, you do not copy and paste the name but rather type it in. This will make sure that non-printable characters do not end up in the names of the file and class as happened.
Upvotes: 1