我似乎无法找到实现jar文件的方法。我创建了一个javase本机接口,尝试将jar文件放在native / javase目录中,并将带有jar文件的cn1Lib文件放在项目的lib目录中。我收到一个错误,该包不存在。 错误:
ant -f C:\\Users\\Robin\\Documents\\NetBeansProjects\\CnoGUIPrac -Dnb.internal.action.name=rebuild clean jar
No GUI Entries available
init:
deps-clean:
Updating property file: C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build\built-clean.properties
Deleting directory C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build
refresh-libs:
Deleting directory C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\lib\impl
clean:
No GUI Entries available
init:
deps-jar:
Created dir: C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build
Updating property file: C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build\built-jar.properties
Created dir: C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build\classes
Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
code size and wider device support
Created dir: C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build\tmp
Compiling 4 source files to C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build\tmp
Created dir: C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build\empty
Created dir: C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build\generated-sources\ap-source-output
Compiling 4 source files to C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build\classes
Copying 3 files to C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build\classes
compile:
Created dir: C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\dist
Copying 1 file to C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build
Not copying library C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\override , it's a directory.
Not copying library C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\lib\impl\cls , it's a directory.
Not copying library C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\lib\impl\stubs , it's a directory.
Not copying library C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\native\internal_tmp , it's a directory.
Copy libraries to C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\dist\lib.
Building jar: C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\dist\CnoGUIPrac.jar
To run this application from the command line without Ant, try:
java -jar "C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\dist\CnoGUIPrac.jar"
Compiling 1 source file to C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\native\internal_tmp
C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\native\javase\com\mycompany\myapp\MyNativeImpl.java:7: error: package main does not exist
import main.UserDB;
C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\native\javase\com\mycompany\myapp\MyNativeImpl.java:18: error: cannot find symbol
UserDB u = new UserDB();
symbol: class UserDB
location: class MyNativeImpl
C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\native\javase\com\mycompany\myapp\MyNativeImpl.java:18: error: cannot find symbol
UserDB u = new UserDB();
symbol: class UserDB
location: class MyNativeImpl
3 errors
C:\Users\Robin\Documents\NetBeansProjects\CnoGUIPrac\build.xml:434: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 3 seconds)
答案 0 :(得分:1)
进一步看一下我认为我的回忆有点模糊,你需要手动将jar文件添加到项目中。
右键单击该项目,然后选择Properties
。在那里选择Libraries
,然后单击Add Jar
将JAR添加到类路径中。