2017-10-27 1 views
1

좋은 하루! 도와주세요, 제발. 나는 더블 클릭 messge 후, jar 파일을 구축 할 것입니다scalaFX 독립 실행 형 jar 파일

sbt> package 

후이 예

sbt> run 

그것은 모든 플레이 좋아요입니다에게, 시동 :

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

스칼라 버전 : 2.12.4을. 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

이것은 자바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 설정도 제거했습니다.

명령을의 지방 JAR을 만들 실행하려면 :

sbt 
sbt> assembly 

당신이 가장 가능성이 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

관련 문제