使用launch4j将jar转换为exe后出现JNI错误

时间:2019-06-14 04:19:25

标签: java exe launch4j

在使用launch4j将我的jar文件转换为exe后,它给了我一个JNI错误,告诉我要检查我的安装,然后再试一次,它给我另一个警告,指出发生了Java异常。

我尝试了不同的方式,例如选择不同的选项,但仍然无法正常工作。

这是日志:

// example-page.js
// +---------------------------------------------------------------------------+
// | ALCA IT SOLUTIONS - Preferred Blank NativeScript Templates                |
// +---------------------------------------------------------------------------+                                                                       |                              |
// | VIEW MODEL Variables                                                      |
// | To access properties within view-model from XML screen:                   |
// |    -- use double curly brackets {{ }}                                     |
// |       example:  <Label text="{{ username }}" />                           |
// |                 <Button text="tap me" tap="{{ myTapMethod }}"/>           |
// | To access functions OUTSIDE of view model from XML screen:                |
// |    -- omit double curly brackets                                          |
// |       example:  <Button text="tap me" tap="myGenericFunction" />          |                                 |                                                                             
// +---------------------------------------------------------------------------+
// | 1. IMPORT REQUIRED FILES                                                  |                                                                        |
// +---------------------------------------------------------------------------+
const  { app }         = require("tns-core-modules/application");
const  { fromObject }  = require("tns-core-modules/data/observable");
var frameModule = require("tns-core-modules/ui/frame");

// Feedback Testing
const  Color  = require("tns-core-modules/color");
const Feedback  = require("nativescript-feedback").Feedback;
const FeedbackType  = require("nativescript-feedback").FeedbackType;
const  FeedbackPosition  = require("nativescript-feedback").FeedbackPosition;
const isIOS  = require ("tns-core-modules/platform");

// +---------------------------------------------------------------------------+
// | 2. CREATE VIEW MODEL                                                      |                                                                        |
// +---------------------------------------------------------------------------+
const model = {

  /* Properties */
  username: "john",
  password: "12345",
  feedback: new Feedback(),
  feedbackPosition: FeedbackPosition,
  feedbackType: FeedbackType,

  /* Methods */
  onNavTap: function(args){
    const navBtn = args.object;
    const page = navBtn.page;
    const btnId = navBtn.id;

    switch(btnId) {
      case "btn-activity":
          //page.frame.navigate("./activity/bloodpressure/bloodpressure");
          break;
      case "btn-programs":
        // code block
          break;
      case "btn-messages":
          // code block
          break;

      case "btn-journal":
          // code block
          break;

      case "btn-community":
          // code block
          break;

    }

    //alert(`${navBtn.id} is the id of the button!`);
    //this.showSuccess();
    this.showError();
    //this.showWarning();
  },

  showSuccess: function() {
    this.feedback.success({
      title: "Successfully shown myself!",
      message: "I'm configured to hide after 2.5 seconds.",
      duration: 2500,
      // type: FeedbackType.Success, // no need to specify when using 'success' instead of 'show'
      onTap: () => {
        console.log("showSuccess tapped");
      }
    });
  },

  showError: function(){
    this.feedback.show({
      title: "Feature Incomplete",
      titleSize: 25.0,
      message: "The Health Conscious feature you are trying to view has not been completed yet. Please check back soon!",
      messageSize: 14.0,
      duration: 5000,
      position: this.feedbackPosition.Bottom,
      type: this.feedbackType.Error,
      onTap: () => {
        console.log("showErrorBottom tapped");
      }
    });
  },

  showWarning: function(){
    this.feedback.show({
      // title: "The warning title",
      message: "This one doesn't have a title, but a very long message so this baby will wrap. Showing off multi-line feedback. Woohoo!",
      duration: 4000,
      position: FeedbackPosition.Top,
      type: FeedbackType.Warning,
      onTap: () => {
        console.log("showWarning tapped");
      }
    });
  }

}

/* Set the binding context */
const bindingContext = fromObject(model);

// +---------------------------------------------------------------------------+
// | 3. OTHER FUNCTIONS ( Not bound to ViewModel )                             |                                                                        |
// +---------------------------------------------------------------------------+
function pageLoaded(args) {
  var page = args.object;
  page.bindingContext = bindingContext;
}

function onDrawerButtonTap(args) {
  const sideDrawer = app.getRootView();
  sideDrawer.showDrawer();
}

// +---------------------------------------------------------------------------+
// | 4. EXPORT OTHER FUNCTIONS                                                 |                                                                        |
// +---------------------------------------------------------------------------+
exports.pageLoaded = pageLoaded;
exports.onDrawerButtonTap = onDrawerButtonTap;

1 个答案:

答案 0 :(得分:0)

这意味着launch4j用于运行程序的JVM版本比编译类fluidDynamicsProject / FluidDynamicSerial的编译器版本要新。您可以尝试在launchj4配置文件中设置最低版本:

<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
  ...
  <jre>
    ...
    <minVersion>11.0</minVersion>
    ...
  </jre>
</launch4jConfig>

请注意,launch4j可能不支持Java的最新版本。

否则,您可以降低用于编译类的目标版本。