For the problem I am facing it is important to know, that we deploy an JavaFX Application with Java 8 (242) together with JavaFX Runtime 202. To build the application we use the javafx packager which creates an EXE-File to launch the application on Windows and deploy the specific runtime next to it.
This way it worked already for years on many different systems until today, where we suddenly have an issue with one specific customer, where the application refuses to launch.
After long time of digging, we learned that our customer launches the application from an UNC Network Path. I tried many UNC aliases and it seems, that the javafx packager generated EXE-File is unable to handle the _ symbol within the host-name section of the UNC path. For example:
\\stack_overflow.de\path\to\application\application.exe
Starting the application using the packager generated EXE results in a Runtime Exception:
java.lang.RuntimeException: No toolkit found
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:209)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
The problem also occurs when using the unchanged javafx example generated with eclipse and using the javafx packager generated EXE file.
The application CFG for the EXE file looks like this:
[Application]
app.name=application
app.mainjar=application.jar
app.version=1.0.3
app.preferences.id=applicationId
app.mainclass=com/path/to/main/Main
app.classpath=libs/somejar.jar;libs/morejars.jar;.
app.runtime=$APPDIR\runtime
app.identifier=applicationId
[JVMOptions]
[JVMUserOptions]
[ArgOptions]
When I start the application by java -jar application.jar everything seems fine. When I start the application from any other mapped network drive, or UNC path without _ the generated EXE launcher file works fine as well.
The exception occurs, when calling the launch method of the Application class:
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
//WE ARE NOT GETTING HERE; WHEN STARTED FROM EXE WITHIN AN UNC PATH WITH '_'
try {
BorderPane root = new BorderPane();
Scene scene = new Scene(root,400,400);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args); //<-- here the error occurs
}
}
Has anyone faced this situation before and knows whether we are doing anything wrong?
Related
I'm not familiar with javaFX I just started.
I import the package and I did The VM option but when I try to add a WebView, ImageView or MediaView in the window I get this error causes
Caused by: java.lang.RuntimeException: Exception in Application start method
Caused by: java.lang.IllegalAccessError: superclass access check failed: class javafx.scene.media.NGMediaView (in unnamed module #0x18ebfb54) cannot access class com.sun.javafx.sg.prism.NGNode (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.sg.prism to unnamed module #0x18ebfb54
All the other contents working fine, button, Slider, and so on
I don't know the problem where, I hope to help me guys Thank you
// code to start bundle
#start
public void startBundle() {
Executors.defaultThreadFactory().newThread(() -> {
Thread.currentThread().setContextClassLoader(
this.getClass().getClassLoader());
launch();
}).start();
}
Bundle is active state after i adding all dependency manager annotations but no screen is displayed.
I have released a couple of first Early Access versions of Drombler FX - the modular application framework for JavaFX.
It's based on OSGi and Maven (POM-first). It integrates OSGi and JavaFX out-of-the-box. Maybe you find it useful. The application framework is Open Source.
There is also a tutorial with a Getting Started page.
Cannot resolve the problem for 2 days already. I have an executable jar, runs with double click. Simple JFrame form. I need to put it on a website, so clicking the link at website should execute my application (my jar).
So, working in NETBEANS, I've created a web application, used Glassfish server. I made a MyServlet.java, which just prints some lines:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<h2>gdfdddddddddddddd</h2>");
// Runtime.getRuntime().exec("java -jar JavaApplication131.jar");
}
}
In index.html this servlet is pointed out:
<body>
<h4>CLick33 MyServlet Page</h4>
</body>
So by clicking the link text appears. No problems with that.
Now I need somehow to also execute my jar. I tried inserting into servlet:
Runtime.getRuntime().exec("java -jar JavaApplication131.jar");
No help. It seems like my jar should be somehow updated with servlet class or connected to separate jar/war, but I cannot figure out how to do it.
Could someone assist please?
You are completely misunderstanding the concept of Servlet and your executable JAR in your question. What you are trying to achieve with your code is to execute the JAR in the context of the Servlet container. The security manager of the servlet container might have restrictions on executing external tools and thus might not execute your external JAR.
What you are asking for is actually to execute the JAR on the users client correct? If this is the case just provide a download link to the JAR and instructions as of how to execute it.
Or even better look into the Java Network Launch Protocol which is specifically designed to launch desktop applications downloaded from web resources.
https://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/jnlp.html
I want users not to download my jar. I wish to store it on server and just open it with a link.
Maybe you can provide some examples?
I'm studying EJB now, and I create a simple EJB example in JBOSS and run successfully, here are my steps:
Create an EJB project in myeclipse
Create an interface named FirstEjb
Create FirstEjbBean implemented the FirstEjb interface, and mark the EJB annotations
#Remote
#Stateless
public class FirstEjbBean implements FirstEjb {
#Override
public String saySomething(String name) {
return "Hello, " + name;
}
}
Create a Java project name "EjbClient" in MyEclipse, export the FirstEjb interface as a *.jar and the new Java project reference to it
Add all the jars in directory "client" of JBOSS to EjbClient project
Create a jndi.properties in the Ejb:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost
7 .Create class FirstEjbClient.java
public class FirstEjbClient {
public static void main(String[] args) throws NamingException {
InitialContext context = new InitialContext();
FirstEjb ejb = (FirstEjb) context.lookup("FirstEjbBean/remote");
String something = ejb.saySomething("Jimmy.Chen");
System.out.println(something);
}
}
And then I can access the EJB successfully.
The question is, I don't know how to do this same in websphere.
There are some questions:
Do I need to config anything in websphere after deploy the EJB project? Like JNDI??
What jars should I import into the Client project? And those jars are in what directory of websphere?
Do I still need the jndi.properties? And how to write it if needed?
I have search on the internet a lot, but all I found is config the data source in websphere.
Sorry for my poor English, hope there is someone can understand it and provide some help.
Thanks in advance!
Jimmy.Chen
Hello,
try this:
Properties props= new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
props.setProperty(Context.PROVIDER_URL,"corbaloc:iiop:localhost:2809");
Context ctx = new InitialContext(props);
Object homeObject = ctx.lookup("some.package.MyEJBRemote");
MyEJBRemote myEJB = (MyEJBRemote) javax.rmi.PortableRemoteObject.narrow(homeObject, some.package.MyEJBRemote);
However I'm not sure about the jars necessary to import, since you can add WebSphere Application Server X runtime library to the buildpath in Eclipse
WAS runtimes for Eclipse are on http://www.ibmdw.net/wasdev/
When you create an EJB project in Eclipse, an EJB deployment descriptor is created. You have to add all your JNDI resources in it, in the references tab.
And you have to add websphere runtime JARs same as you have added any other JARs.
Hi I have written a script using HTMLUnit that fetches a web page given a url and performs certain operations on them. For instance searching for a string on a page or clicking on a link and so on. I am creating a runnable jar using eclipse IDE.
HTML-Unit consists of about 21 different library jars that i am extracting in my single final runnable jar. These dependencies cause the single jar to occupy a space of about 9.3MB. I have been trying to reduce the individual jar size using obfuscation. I am using a tool called proguard for it.
Here is a sample proguard configuration i am using to obfuscate a single library jar by the name of "commons-logging-1.1.1.jar":
`-libraryjars <java.home>/lib/rt.jar
-injars C:/Users/Desktop/Jars/commons-logging-1.1.1.jar
-outjar C:/Users/Desktop/SmallJars/commons-logging-1.1.1.jar
-printmapping C:/Users/Desktop/SmallJars/out_commons-logging-1.1.1.map
-renamesourcefileattribute SourceFile
-dontnote
-keepattributes InnerClasses,SourceFile,LineNumberTable,Deprecated
-keep public class * {
public protected *;
}
-keepclassmembernames class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers class * implements java.io.Serializable
{
static final long serialVersionUID;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}`
The config is pretty much the same as one given on the proguard website in usage -> typical libraries. On rebuilding the project in eclipse using these 21 reduced jars and running it, the script fails at runtime with the exception:
"java.lang.NoSuchMethodException: org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext()"
Looks like i have obfuscated the individual jars in a manner that certain methods will now not be found. Could you guide me as to what may be causing these exceptions. and is there something wrong with the config file above.If
so what would be the best proguard configuration for this scenario.
I am aware another member was chasing a similar problem. The question is posted at link:
[a link] (Determine used libraries to reduce JAR file size)
Thank you!!
The method is accessed by reflection, which ProGuard can't know from its static analysis. You have to preserve it in your configuration. Cfr. ProGuard manual > Troubleshooting > NoSuchMethodException.
Processing the application as a whole will be much more effective than processing the libraries individually, because ProGuard may then remove entirely unused libraries or at least larger parts of them.