Advertisement

02.19.2008 at 02:11PM PST, ID: 23175897
[x]
Attachment Details

javah -jni problem with compiling my package

Asked by asmyatt in Java Native Interface (JNI), Sun Solaris, Java Programming Language

Tags: java

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/TestApp/com/MyPackage/

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.Abort
        at com.sun.tools.javac.comp.Check.completionError(Check.java:169)
        at com.sun.tools.javadoc.DocEnv.loadClass(DocEnv.java:149)
        at com.sun.tools.javadoc.RootDocImpl.<init>(RootDocImpl.java:77)
        at com.sun.tools.javadoc.JavadocTool.getRootDocImpl(JavadocTool.java:156)
        at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:330)
        at com.sun.tools.javadoc.Start.begin(Start.java:128)
        at com.sun.tools.javadoc.Main.execute(Main.java:66)
        at com.sun.tools.javah.Main.main(Main.java: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
 
 
[+][-]02.19.2008 at 04:18PM PST, ID: 20933934

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 08:45PM PST, ID: 20935158

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Native Interface (JNI), Sun Solaris, Java Programming Language
Tags: java
Sign Up Now!
Solution Provided By: cmalakar
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628