JonathanGiles / scenic-view

Scenic View is a JavaFX application designed to make it simple to understand the current state of your application scenegraph, and to also easily manipulate properties of the scenegraph without having to keep editing your code. This lets you find bugs, and get things pixel perfect without having to do the compile-check-compile dance.
GNU General Public License v3.0
531 stars 69 forks source link

can not open the jar file #57

Closed aliShreef closed 4 years ago

aliShreef commented 4 years ago

I am trying to run the jar file from lib folder , but nothing happen.

also i tried to run it from CMD but i got this message :

image

and this is my JAVA_HOME & JRE_HOME variable.

image

thank you.

Oliver-Loeffler commented 4 years ago

I have now played with JDK-8 and JDK-11 versions using Windows command line.

git clone --branch jdk-8 https://github.com/JonathanGiles/scenic-view.git
cd scenic-view
gradle assemble run

For the current JDK-11 compatible version, this worked:

git clone https://github.com/JonathanGiles/scenic-view.git
cd scenic-view
gradlew build run

When starting manually, ensure that the JavaFX runtime is available (https://openjfx.io) One can download the runtime here: https://gluonhq.com/products/javafx/

set PATH_TO_FX="path\to\javafx-sdk-11\lib"

Then continue building and running the Scenic-View. Scenic-View requires different JavaFX modules. Manually launching Java requires to provide the individual modules. The module javafx.base must not be provided manually, as it is a transitive depenedency of the other modules.

git clone https://github.com/JonathanGiles/scenic-view.git
cd scenic-view
gradlew build
cd build\libs
java --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.graphics,javafx.fxml,javafx.web -jar scenicview.jar

Well, having JDK-11 installed in Windows, on PowerShell it worked for me like that:


$env:JAVA_HOME="C:\Program Files\Java\jdk-11.0.2"
$env:PATH_TO_FX="D:\Test3\javafx-sdk-11.0.2\lib"
Set-Alias java "C:\Program Files\Java\jdk-11.0.2\bin\java.exe"

cd D:\Test3
git clone https://github.com/JonathanGiles/scenic-view.git
cd scenic-view
./gradlew assemble

cd build/libs
java --module-path $env:PATH_TO_FX --add-modules javafx.controls,javafx.graphics,javafx.fxml,javafx.web -jar .\scenicview.jar

Not to forget, the $env:PATH_TO_FX= setting is adjusted to my system. This must be customized.

snippet

Oliver-Loeffler commented 4 years ago

According to build.gradle, the JavaFX Swing module is needed as well. This will be relevant, when the JFXPanel is used in the project to be analysed. In this case, the java command shall look as follows:

java --module-path $env:PATH_TO_FX --add-modules javafx.controls,javafx.graphics,javafx.fxml,javafx.web,javafx.swing -jar .\scenicview.jar
aliShreef commented 4 years ago

@Oliver-Loeffler , thank you so much for your valuable replay to my point. actually i am able to run the jar now from power shell with this command :

java --module-path $env:PATH_TO_FX --add-modules javafx.controls,javafx.graphics,javafx.fxml,javafx.web,javafx.swing -jar .\scenicview.jar

, but nothing display. look :

image

also, when i follow your way for JDK 11 , i got this error when run this command :

gradlew build run

image

note that , i set PATH_TO_FX as it is as variable name , and set the value of the variable to my local javaFX SDK lib directory

aliShreef commented 4 years ago

should i start my application along with scenic-view in order to load the hierarchy of view ?

Oliver-Loeffler commented 4 years ago

In PowerShell instead of gradlew build run you must type ./gradlew build run. Yes, you have to run your application along with Scenic-View. Scenic-View permanently scans for JavaFX applications around.

The ThreeDom will only work, when started as a project dependency. Well, I haven't this tried yet with JDK-11 version.

Button button = new Button("Hello");
VBox vbox = new VBox(button);  
Scene scene = new Scene(vbox);
primaryStage.setScene(scene);
primaryStage.show();

// only works, if Scenic-View has been added as a dependency to your project
ScenicView.show(scene);
aliShreef commented 4 years ago

i do not know what i say actually , you save my all life.

currently i am able to run the jar from power shell correctly , but i still can not run it by just double click. when i double click jars , nothings is happen and when i run from power shell like this

image

i got

classNotFoundException

what is the issue or i am missing if i am able to run it from power shell but not from just clicking on it ?

Oliver-Loeffler commented 4 years ago

Double clicking the JAR is equivalent to the attempt of running the jar with javaw -jar scenicview.jar or java -jar scenicview.jar. The required dependencies (in module path) are not available, thus there will be a ClassNotFoundException somewhere.

Instead, you could write a BATCH or CMD file which is then executed, it could look like:

start-scenic-view.cmd

@echo off
javaw --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.graphics,javafx.fxml,javafx.web -jar %LOCATION_OF_JAR%\scenicview.jar

This batch file will be runnable via double click. Well, it would be also possible to create an image with JLink but here I am not yet so familar with.

aliShreef commented 4 years ago

Thank you so much for your support @Oliver-Loeffler , you help me a lot. i appreciate it .