SceneBuilder Kit crippled by Gluon charm hidden dependency? - scenebuilder

Downloaded Gluon Scene Builder Kit. Upon execution the program will crash during "EditController" creation - instancing.
Tried older versions and scoured the net to no avail. The range of options are (to me) limited as there are hidden dependencies is closed libs.
public class Main extends Application
{
#Override
public void start(Stage primaryStage) throws Exception
{
EditorController editor_controller = new EditorController();
...
...
}
public static void main(String[] args){ launch(args); }
}
I expected to see at the least the content pane but instead got:
"java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lau
...
Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.control.AppBar
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 13 more"

Solved the issue by adding "charm-glisten-5.0.2.jar" to the project references (I'm using IntelliJ btw). Which Jar is NOT referenced anywhere on - in the SceneBuilder kit download download section, or the site.
So, if one wishes to expose scene builder in YOUR app, NOT simply to integrate it into your IDE, then make sure you add the above jar as a reference to your project. It can be found in the repo at https://nexus.gluonhq.com/nexus/content/repositories/releases/com/gluonhq/charm-glisten/5.02/

Related

executable jar not opening when used with getResources (but works with an absolute file path) in JavaFX

Problem:
Changing two lines of code makes the executable jar go from opening and working perfectly to not opening (even though it runs in Eclipse).
Description:
I have made an application in JavaFX using local file directories (silly I know) to access a .jpg file and I can deploy it as an executable and it works great on my computer using this code snippet.
Obviously, another computer will be unable to access my files so I converted the files into a more universal form so anyone who uses the application would be able to view the file.
A problem arises somehow when I create a .jar executable. The .jar opens and works great when using the absolute path but when I change only 2 lines the .jar executable will not open.
Here is the full code.
package workingSamples;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ImageDisplay extends Application {
#Override
public void start(Stage stage) {
stage.setTitle("HTML");
stage.setWidth(500);
stage.setHeight(500);
Scene scene = new Scene(new Group());
VBox root = new VBox();
final ImageView selectedImage = new ImageView();
File file = new File( "C:\\Users\\Documents\\logo.jpg" );
Image image1 = new Image( file.toURI( ).toString( ), 500, 200, true, true );
//Image image1 = new Image(ImageDisplay.class.getResourceAsStream("logo.jpg"), 500, 200, true, true);
selectedImage.setImage(image1);
root.getChildren().addAll(selectedImage);
scene.setRoot(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
This .jar executes and opens with no errors but if I uncomment the one commented line (and comment out the two above it) the project works in Eclipse but it will not open any time when I export as an executable. And I get this error every time when I try to export it:
Exported with compile warnings: WorkingSamples/src/workingSamples/ImageDisplay.java
I have tried storing the data in both the bin and src, restarting Eclipse, making sure Debug mode is not running, trying every type of library handling. Maybe it is a permission issue but I do not know how to try to fix that.
Any help would be greatly appreciated! Thank you in advance :)
(I have tried the fixes from javafx jar builds fine but doesn't open (unfortunately I do not have command line access due to company security constraints) and Can't run javafx JAR outside Netbeans (I don’t believe there are any libraries that need to be imported but are not) and Unable to run Javafx from computer by double clicking the jar file (I have the latest version of Java installed) and Eclipse - error executable jar file (I tried all library handling options but maybe it’s a permission issue which I do not know how to fix))
Code inspired from this example:
ANT file output:
<?xml version="1.0" encoding="UTF-8"?>
<project name="Create Runnable Jar for Project WorkingSamples with Jar-in- Jar Loader" default="create_run_jar">
<!--this file was created by Eclipse Runnable JAR file Export Wizard-->
<!--ANT 1.7 is required-->
<!--define folder properties-->
<property name="dir.buildfile" value="."/><property name="dir.workspace" value="C:/Users /Documents/Eclipse"/><property name="dir.jarfile" value="${dir.buildfile}"/><target name="create_run_jar"><jar destfile="${dir.jarfile}/workingSamples7.jar"><manifest><attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/><attribute name="Rsrc-Main-Class" value="workingSamples.ImageDisplay"/><attribute name="Class-Path" value="."/><attribute name="Rsrc-Class-Path" value="./ org.eclipse.fx.ide.css.jfx8_2.3.0.201603030809.jar"/></manifest><zipfileset src="jar-in-jar-loader.zip"/><fileset dir="${dir.workspace}/WorkingSamples/bin"/><zipfileset dir="C:/Users /Documents/ eclipse-java-mars-R-win32-x86_64/eclipse/plugins" includes="org.eclipse.fx.ide.css.jfx8_2.3.0.201603030809.jar"/></jar></target> </project>
The base directory of getResourceAsStream(...) is your jar root. I would suggest to place your image into a resource folder (in your case) WorkingSamples/resources/logo.jpg afterwards you can access the image with
Image image1 = new Image(ImageDisplay.class.getResourceAsStream("/resources/logo.jpg"), 500, 200, true, true);
Another thing you can check is if the ant script puts the image into the right place inside of the jar

Reflection error with self-hosted nancyfx app on mono

After building and successfully running a self-hosted NancyFx application on windows with visual studio I went on and tried to run the application on linux with mono. I was able to build the solution (using xbuild) but when running the app I get a strange error:
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
System.TypeLoadException: Could not load type 'System.Net.HttpListener'
from assembly 'System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'.
at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Initialize (IDictionary`2 properties) <0x413ae4f0 + 0x000eb> in <filename unknown>:0
For some reason, the app tries to initialize class HttpListener from the System assembly, but HttpListener lives in System.Netassembly. I looked in the GAC folder and found that System.Net is there as expected. I moved a copy to the bin folder where the other dependencies of the app live but that didn't solve the problem. Any help would be appreciated!!
here is my OWIN-related code:
// Startup.cs
using Owin;
namespace MyApp
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseNancy();
}
}
}
// Program.cs
using System;
using Microsoft.Owin.Hosting;
namespace MyApp
{
public class Program
{
static void Main(string[] args)
{
var url = "http://127.0.0.1:8080/";
using (WebApp.Start<Startup>(url))
{
Console.WriteLine("Running on {0}", url);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
}
}
}
Yep, wrong assembly indeed.
Im not sure why yet, but I'm having the same issue with CENTOS only using mono 4.3.178. Debian Jesse using version 4.2.x had no issues. Several other Debian Jesse boxes I use to test seem to have no issues with 4.3.x. In my case I'm listening on an alternate port.
RedHat Strikes Again :/
A MUCH deeper stack trace into the IL seems to indicate that gcc on the machine you built mono on, and also the build essentials package have some extremely dated libs and even the compiler. I was surprised to see the number of warnings, nearly 70,000 as opposed to a typical 400 depending on the diversity of libs you have. I have about 10 hours to figure this out, so hopefully its not too bad.

javafx.application.Application class in not not importing in eclipse

i have install java 8 and eclipse luna when i am trying to import javafx.application package it will not showing the Application class i have add jar called jfxrt but it is not working**
import javafx.application.;
public class FxExample {
public static void main(String[] args) {
}
}
Please make yourself familiar with the JavaFX language and read at least the documentation about how to implement Hello World, JavaFX Style.
Since you are on eclipse instead of NetBeans, I rather suggest you get e(fx)clipse instead of trying to get it to work manually. Just download the package, install it and you're good to start developing.

How to run standalone TestNG project from jar/bat/

I have a TestNG project. Don't have any main class, currently it is running like "Run As TestNG".
I want to export it as runnable jar or jar so that any one can just hit a command from command line and test cases start running.
Could any one help me out in this? or suggest any other way to deliver the code in runnable form...
I am not using ant or maven.
Thanks
I seem to have found the solution after a bit of googling. This works fine in Eclipse (Juno).
Say, you have a TestNG file named 'Tests.java'. As you rightly pointed out, there won't be a class with main method.
So, we have to create a new Java class file under the same package. Let us name it 'MainOne.java'. This will have a class with main method.
Here is the code you need:
import com.beust.testng.TestNG;
public class MainOne {
public static void main(String[] args) {
TestNG testng = new TestNG();
Class[] classes = new Class[]{Tests.class};
testng.setTestClasses(classes);
testng.run();
}
Run the 'MainOne.java' as a Java application. Then right click on the package -> Export -> Runnable Jar [Choose 'MainOne' as Launch Configuration] -> Finish.
My current understanding is that, in order to benefit from the parallel niftiness of TestNG, one should use the static main method in org.testng's jar file when running the Java class from the command line rather than from inside Eclipse IDE.
The issue then becomes classpath, which defines how java finds all the JAR files. I found http://javarevisited.blogspot.com/2012/10/5-ways-to-add-multiple-jar-to-classpath-java.html to be most useful because it has the * wildcard mentioned --- VERY helpful when you need to reference all the jar files required for Selenum + TestNG + custom test suites.
This is my current Windows BAT file, and it works. ADV.jar contains my custom class but no main method.
setlocal
set r=d:\Apps\Selenium\
cd /d %~dp0
java -classpath %r%Downloaded\*;%r%MyCompany\ADV.jar; org.testng.TestNG .\testng-customsuite-adv.xml
pause
All the JAR files that I downloaded from public places went into my d:\Apps\Selenium\Downloaded folder. I put my custom ADV.jar file in d:\Apps\Selenium\MyCompany to keep it separate.
I created my ADV.jar file from Eclipse using Export Jar file and ignored warnings about a missing main method.
Aside: while this https://stackoverflow.com/a/16879386/424855 was very intriguing, I could not figure out how to make that work.
Here is the better way to do it.
You can just create a main method which will have list of all test classes to be executed as follows:
public static void main(String[] args) {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { test_start.class });
testng.addListener(tla);
testng.run();
}
Here is the reference URL from the official testng website.
Run the MainOne.java as a Java application. Then right click on the package -> Export -> Runnable Jar [Choose MainOne as Launch Configuration] -> Finish.

Eclipse RCP: ClassNotFoundException or How to make other bundle load my class

Details: I'm trying to use Jalapeno framework to connect my RCP app with Cache' database. After connection established, I'm trying to get all data from table exactly like in Jalapeno manual:
if (objManager==null) return;
DBClass cortege = null;
try {
Iterator terms = objManager.openByQuery(DBClass.class, null, null);
System.out.println("terms ok");
while (terms.hasNext()){
System.out.println("has next");
cortege = (DBClass)terms.next();
}
this code compiling, running and trowing exception
java.lang.RuntimeException: myPluginId.views.DBClass
at com.intersys.objects.POJOIterator.next(POJOIterator.java:75)
...skip...
Caused by: java.lang.ClassNotFoundException: myPlugin.views.DBClass
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass(ContextFinder.java:129)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.jalapeno.runtime.ObjectCopierToPojo.detach(ObjectCopierToPojo.java:76)
at com.jalapeno.runtime.ObjectCopierToPojo.findPojo(ObjectCopierToPojo.java:472)
at com.intersys.classes.CacheRootObject.detach(CacheRootObject.java:255)
at com.intersys.classes.Persistent.detach(Persistent.java:567)
at com.intersys.objects.POJOIterator.next(POJOIterator.java:59)
at terms.next();
I can't get it at all... instance of class DBClass was just created, but class cannot be loaded.
then I've tried to place this code in simple java application (not eclipse rcp) and all went ok. so I think some Eclipse part blocking class loading.
also i've tried to load class before calling terms.next();
Bundle b = Platform.getBundle("myPluginId");
try {
b.loadClass("DBClass");
} catch (ClassNotFoundException e) {
System.out.println("no class");
e.printStackTrace();
}
...and got same error. Class can not be loaded.
So, is it a known problem? Is there a solution?
Update
After some research updating the question:
How to make Jalapeno plugin to load class from My plugin?
You might want to try buddy classloading. For more info on Eclipse classloading, Alex Blewitt has written an excellent overview of the classloading system in Eclipse here. Its a few years old, but for the most part it is still relevant.
The jist of buddy classloading is this:
a plugin declares that it needs help loading classes. It does this by declaring its "buddy plugin"
the buddy plugin declares its buddy policy
when the regular loading mechanism fails, Eclipse tries to use the buddy classloading policies you have specified.
So in your case, try putting:
Eclipse-BuddyPolicy: registered
in your Jalapeno plugin's manifest.mf file
and put:
Eclipse-RegisterBuddy: id.of.jalepeno.plugin
in the manifest.mf of your plugin
I am not sure, but maybe you have to export the package in which the classes are lying.
Select in the MANIFEST "Runtime" and add all packages

Resources