i'm trying to compile some java code on Solaris 10.
let's say I have the class MyClass in the file MyClass.java and it is located in the directory /export/home/asmyatt/TestA
pp/com/MyP
ackage/
at the top of MyClass.java I have
package com.MyPackage;
Then I do the following:
javac MyClass.java *** It compiles with no errors ***
javah -jni MyClass
When I run this statement I get the following error:
error: cannot access MyClass
bad class file: ./MyClass.class
class file contains wrong class: com.MyPackage.MyClass
Please remove or make sure it appears in the correct subdirectory of the classpath.
com.sun.tools.javac.util.A
bort
at com.sun.tools.javac.comp.C
heck.compl
etionError
(Check.jav
a:169)
at com.sun.tools.javadoc.DocE
nv.loadCla
ss(DocEnv.
java:149)
at com.sun.tools.javadoc.Root
DocImpl.<i
nit>(RootD
ocImpl.jav
a:77)
at com.sun.tools.javadoc.Java
docTool.ge
tRootDocIm
pl(Javadoc
Tool.java:
156)
at com.sun.tools.javadoc.Star
t.parseAnd
Execute(St
art.java:3
30)
at com.sun.tools.javadoc.Star
t.begin(St
art.java:1
28)
at com.sun.tools.javadoc.Main
.execute(M
ain.java:6
6)
at com.sun.tools.javah.Main.m
ain(Main.j
ava:147)
javadoc: error - fatal error
2 errors
**************************
***
If I remove the package statement at the top it works fine. The only problem then is i don't know how to get the additional classes in the package to see the compiled class file.
I would prefer that it let me put this class in the package. Any suggestions as to what I'm doing wrong?
Start Free Trial