2017-10-27 21 views
1

おはよう!お願い助けて。scalaFXスタンドアロンでjarファイルを実行

Error: A JNI error has occured, please check your installation and try again.

Scalaのバージョン:2.12.4私は

sbt> package 

をダブルクリックmessge後、jarファイルを構築します後それは、すべてのプレイオーケーだ

sbt> run 

この例を起動します。 JVM:1.8.0_152。 ScalaFX:8.0.102-R11

hello.scala: `

package hello 

import scalafx.Includes._ 
import scalafx.application.JFXApp 
import scalafx.application.JFXApp.PrimaryStage 
import scalafx.scene.Scene 
import scalafx.scene.paint.Color._ 
import scalafx.scene.shape.Rectangle 

object HelloStage extends JFXApp { 

    stage = new JFXApp.PrimaryStage { 
    title.value = "Hello Stage" 
    width = 600 
    height = 450 
    scene = new Scene { 
     fill = LightGreen 
     content = new Rectangle { 
     x = 25 
     y = 40 
     width = 100 
     height = 100 
     fill <== when(hover) choose Green otherwise Red 
     } 
    } 
    } 
} 

build.sbt:

name := "Scala" 

organization := "scalafx.org" 

version := "1.0.5" 

scalaVersion := "2.12.4" 

scalacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8") 

resourceDirectory in Compile := (scalaSource in Compile).value 

libraryDependencies ++= Seq(
    "org.scalafx" %% "scalafx" % "8.0.102-R11",) 

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full) 

fork := true 

答えて

0

これはJavaのclasspath問題です。結果のJARファイルを実行しようとすると、実行する必要があるjarファイルが見つかりません。

次のことを試してみてください。まず

project/plugins.sbtに以下を貼り付け&をコピーします。

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5") 

これは、すべてを含む、脂肪JARファイルを作成しますsbt-assemblyプラグインをロードします依存関係。

第二に、次のようにあなたのbuild.sbtファイルを変更します。

name := "Scala" 

organization := "scalafx.org" 

version := "1.0.5" 

scalaVersion := "2.12.4" 

scalacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8") 

libraryDependencies += "org.scalafx" %% "scalafx" % "8.0.102-R11" 

fork := true 

mainClass in assembly := Some("hello.HelloStage") 

これは、あなたがもともと持っていたものが簡素化されます。 マクロパラダイスコンパイラプラグインは必要ありません。少し奇数resourceDirectoryの設定も削除しました。

sbt 
sbt> assembly 

あなたが探しているJARファイルが最も可能性の高いtarget/scala-2.12/Scala-assembly-1.0.5.jarに配置されています、脂肪JARを作成するコマンドを実行するには

。あなたは今すぐ行くべきです。

また、add all the necessary JAR files to your classpathもできます。それを助ける別のプラグイン(おそらくsbt-assemblyと一緒に使用しないでください)はsbt-native-packagerで、インストーラが作成されます。その後、あなたのアプリケーションをインストールし、通常のアプリケーションのように実行することができます。

+0

ありがとう、非常に!!!!!これでOK! – Dima

関連する問題