質問

I tried to create .c and .h files from my class and got a really strange problem. While javah creates a .h file from my .java file perfectly - javac doesn't create a .c file, instead it creates .class file with no errors in logs!

Java source:

package com.iiordanov.bVNC;

//import java.io.IOException;

public class NativeCalls {
    static
    {
        System.loadLibrary("start-spice-xml");
    }
   public native static  String[] getPortAndPassword(String server, String name);//  throws IOException;
}

I am currently running on Fedora. When I try to run from src folder:

javac com/iiordanov/bVNC/NativeCalls.java

it creates NativeCalls.class, but I need .c style class. On the other hand,

javah -jni com.iiordanov.bVNC.NativeCalls

works perfectly and creates com_iiordanov_bVNC_NativeCalls.h.

How can I generate a .c file from my Java source code?

役に立ちましたか?

解決

Javac is not meant to create C files. It's a Java compiler - source to bytecode.

If you want a C file with empty implementations for your native functions, pass the -stubs option to javah.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top