Jump to content

JavaFX with ForgeGradle


DerTod2

Recommended Posts

Hi,

 

Is it possible to compile Mods using JavaFX (using jdk 1.8.0) with ForgeGradle? Currently the build throws "unknown package"

Can I add additional dependencies anywhere?

 

build.log:

 

 

****************************

Powered By MCP:           

http://mcp.ocean-labs.de/ 

Searge, ProfMobius, Fesh0r,

R4wk, ZeuX, IngisKahn     

MCP Data version : unknown

****************************

:compileApiJava UP-TO-DATE

:processApiResources UP-TO-DATE

:apiClasses UP-TO-DATE

:sourceMainJava

:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:5: error: package javafx.scene does not exist

import javafx.scene.Scene;

                  ^

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:6: error: package javafx.scene.web does not exist

import javafx.scene.web.WebView;

                      ^

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:7: error: package javafx.stage does not exist

import javafx.stage.Stage;

                  ^

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:8: error: package javafx.stage does not exist

import javafx.stage.StageStyle;

                  ^

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:11: error: cannot find symbol

private Stage stage;

        ^

  symbol:  class Stage

  location: class YoutubePlayer

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:12: error: cannot find symbol

private WebView webView;

        ^

  symbol:  class WebView

  location: class YoutubePlayer

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:17: error: cannot find symbol

this.stage = new Stage(StageStyle.TRANSPARENT);

                ^

  symbol:  class Stage

  location: class YoutubePlayer

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:17: error: cannot find symbol

this.stage = new Stage(StageStyle.TRANSPARENT);

                      ^

  symbol:  variable StageStyle

  location: class YoutubePlayer

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:18: error: cannot find symbol

this.webView = new WebView();

                  ^

  symbol:  class WebView

  location: class YoutubePlayer

C:\Users\DerTod2\Desktop\Forge\build\sources\java\net\dertod2\UnitedMC\Classes\YoutubePlayer.java:31: error: cannot find symbol

this.stage.setScene(new Scene(this.webView));

                        ^

  symbol:  class Scene

  location: class YoutubePlayer

Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

Note: Some input files use unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

10 errors

1 warning

FAILED

 

FAILURE: Build failed with an exception.

 

* What went wrong:

Execution failed for task ':compileJava'.

> Compilation failed; see the compiler error output for details.

 

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

 

BUILD FAILED

 

Total time: 7.939 secs

 

 

Link to comment
Share on other sites

Well now ForgeGradle compiles succesfully with these lines in the gradle.build:

 

dependencies {
  compile files("C:/Program Files/Java/jdk1.8.0_05/jre/lib/ext/jfxrt.jar")
}

 

The next problem (maybe an java problem?) is the NoClassDefFound Exception when running the mod and starting to play an youtube video. Java throws this exception:

 

 

 

java.lang.NoClassDefFoundError: javafx/scene/Parent

at net.dertod2.UnitedMC.Classes.PlayerWrapper.getInstance(PlayerWrapper.java:22)

at net.dertod2.UnitedMC.Classes.Plugins.MusicSystemPlugin.onGameTick(MusicSystemPlugin.java:185)

at net.dertod2.UnitedMC.Binary.UnitedMinecraftMod.onGameTick(UnitedMinecraftMod.java:166)

at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_UnitedMinecraftMod_onGameTick_ClientTickEvent.invoke(.dynamic)

at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51)

at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122)

at cpw.mods.fml.common.FMLCommonHandler.onPreClientTick(FMLCommonHandler.java:307)

at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1574)

at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:955)

at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:873)

at net.minecraft.client.main.Main.main(SourceFile:103)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

Caused by: java.lang.ClassNotFoundException: javafx.scene.Parent

at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:188)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

... 17 more

 

 

 

Eclipse throws no warnings and the lib should be in every Oracle Java Installation. Then why is the class "javafx.scene.Parent" missing O.o...

 

The java File containing the JavaFX imports looks like this:

 

 

 

package net.dertod2.UnitedMC.Classes;

import java.io.File;

import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class YoutubePlayer extends PlayerWrapper {
private Stage stage;
private WebView webView;

protected YoutubePlayer(MusicTitle musicTitle, long timeDifference, long startedAt) {
	super(musicTitle, timeDifference, startedAt);

	this.stage = new Stage(StageStyle.TRANSPARENT);
	this.webView = new WebView();
}

@Override
public void stop() {
	this.webView.getEngine().load("http://localhost"); // Force load simple document
}

@Override
public boolean play(File file) {
	this.webView.getEngine().load(this.getTitle().getPath() + "?autoplay=1&t=" + this.getStartTime());

	this.webView.setPrefSize(1, 1);
	this.stage.setScene(new Scene(this.webView));
	this.stage.show();

	return true;
}

private String getStartTime() {
	long differenceMilliseconds = ((System.currentTimeMillis() - this.getStarted()) + this.getDifference());
	return (differenceMilliseconds / 1000) + "s";
}

public long getSongLength() {
	// TODO Auto-generated method stub
	return 0;
}

public boolean isPlaying() {
	return false; // TODO
}

public long getProgress() {
	return 0;
}

public void setVolume(float volume) {
	// TODO Auto-generated method stub

}

}

 

The problematic line should be "this.stage.setScene(new Scene(this.webView));"

 

 

 

Thanks for the Help!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.