Comments (71)
from update4j.
No.
The central philosophy in update4j is not to rely on a new JVM instance. It's true that you can't call javafx.application.Application::start
twice, but there are minimum 2 ways for doing it in a single instance.
Make primaryStage
global static variable and change scene. The same stage you use for the splash/installer can be reused in the business app. When launching the business app, don't call Application.start()
, don't even subclass Application
in first place. Just replace the scene and you're good to go.
Create new stage. If you prefer not to create a global object (they are evil), you can close the primary stage used for installation/progress, and create new stages in the business app. Once again you shouldn't call Application.start()
.
Also I'm still a bit unclear on what needs to be done if the updater app itself requires updates, since the updaterapp jar will be locked while it is running.
Here's where the delegation feature comes in. Since you can't overwrite locked files in Windows (and you shouldn't overwrite in Linux) you simply remove the old delegate from the config and list a complete new one (with a new filename), just remember to increment the Delegate::version
number, and -- if you're using modules -- give it a new module name. The delegation system will choose the highest version.
In delegate mode you must start the framework using the built-in main method. Refer to Starting the Application.
from update4j.
Now I can get things working beautifully with default setup or from and unupdateable updater jar but I would like to use delegate mode.
What I'm still not understanding is exactly how to inform update4j main method on where to get the delegate. (btw this is first time I'm dealing with Java modulepaths)
I have tried to make a JAR with CustomBootstrap, CustomLauncher and module.info.class
module.info:
module TestModuleAlpha {
requires org.update4j;
provides org.update4j.service.Delegate with com.testing.CustomBootstrap;
}
in config I have <provider launcher="CustomLauncher"/>
and <file path="TestiModule.jar" size="16852" checksum="12730227" modulepath="true"/>
TestiModule.jar is the jar containing the CustomLauncher and CustomBootstrap.
I'm still getting "CustomLauncher not found between providers for org.update4j.service.Launcher, using org.update4j.service.DefaultLauncher instead."
from update4j.
Don't use the launcher
element in the config, it is misleading and was probably a mistake to add it in the framework in first place. The purpose is to override the versioning. Even if you do use it, it requires a fully qualified name. Don't forget the provides
directive in launcher too.
For the bootstrap to work it must be visible to the modulepath. Check out Starting the Application.
from update4j.
For the bootstrap to work it must be visible to the modulepath.
How do I do that? I just can't figure it out from the wiki.
from update4j.
from update4j.
-p CustomModule.jar -m newpackage.CustomModule
Like so?
module-info.java of CustomModule:
module CustomModule { requires org.update4j; provides org.update4j.service.Delegate with newpackage.CustomBootstrap; provides org.update4j.service.Launcher with newpackage.CustomLauncher; }
I'm just not getting it >_<
from update4j.
from update4j.
Finally I got it working like I wanted. I hadn't realized I need to have the custom stuff in a separate directory. Now it all seems clear now. It is my first time looking into java 9 module system. It starts to make a little sense.
Thank you so much for help!
from update4j.
Would it be possible to publish source code for the example JavaFX delegate shown in readme that launches hello-world.jar? I'm still having trouble handing over the primaryStage to business jar after launching javafx on Custom update handler. It might help others too.
from update4j.
from update4j.
OK, thank you. 👍
Even the 1.0.0-beta version delegate could be useful, I just need to be pointed to right direction.
from update4j.
I'm currently a bit busy on a paid contract and the source used needs some work to make it work with the current update4j version (was created with version 1.0.0-beta). Will try to find time for it soon.
Had any more time to think about this? 👍
from update4j.
Let me make it stand out so I won't forget.
from update4j.
Now i am able to use the standard mode with default setting without any issues.But i would like to use delegate mode.
Is there any sample project for delegate mode setup.
I gone through the document,but i couldn't get the solution.
Could you please suggest where to start for the delegate mode ?
In addition to this i would like to know whether update4j works with Proxy authentication.?
How to use proxy authentication ?
Thanks.
John
from update4j.
you simply remove the old delegate from the config and list a complete new one (with a new filename), just remember to increment the Delegate::version number
Am I right to assume that the new delegate should also use another package than the previous delegate, because having multiple classes with the same fully qualified class names on the classpath would be a horrible idea?
from update4j.
from update4j.
Just for reference, I had issues with the classloader when using Swing in both the bootstrap and the business application. I post this here, because the pitfalls when using Swing with update4j are probably similar to JavaFX.
The issue was that the business application could not find resources (images and icons) when searching for them from inside the EDT (Event Dispatcher Thread), because the Context-Classloader of the EDT was still set to the app-classloader of the bootstrap.
The workaround is to call this in Launcher.run(LaunchContext context)
just before the handover to the business application:
EventQueue.invokeLater(
() -> Thread.currentThread().setContextClassLoader(context.getClassLoader()));
Ugly, but there doesn't seem to be another way to reset the context classloader of the EDT. Still, this method fails like one in ten times. I don't know why yet.
from update4j.
Hi,
I am trying to create updater in delegate mode.
I have created jar with CustomBootstrap implements Delegate and CustomLauncher implements launcher classes.
and my module-info contains
module ediLauncher {
exports com.ediLauncher;
requires org.update4j;
provides org.update4j.service.Delegate with com.ediLauncher.EDIBootstrap;
provides org.update4j.service.Launcher with com.ediLauncher.EDIUpdateLauncher;
}
How to use this in my JavaFX application?
It would be very helpful if you publish the source code for JAVAFX hello world project.
Thanks,
John.
from update4j.
from update4j.
My Business application is JavaFX application,For that i want to create auto updater.
So i tried Update4j.In standard mode i could open my business app.
Now i am trying to use delegate mode.
Thanks,
John
from update4j.
Yes i want to run the Bootstrap also in JavaFX..
from update4j.
In your JavaFX demo,
does delegate.jar contain main method which calls Application::start () method?
or it implements Delegate interface from Update4j?
If it implements Update4j's Delegate Interface,then which main method will be called?
How did you update the progress bar from UpdateHandler class?
Thanks,
John.
from update4j.
How did you update the progress bar from UpdateHandler class?
You need to implement your own Delegate. From there, when calling Configuration.update(..)
, use the overload that also accepts the parameter Consumer<? super UpdateHandler> handlerSetup
. You can use this overload to inject stuff into your UpdateHandler.
For example, I pass a java.util.DoubleConsumer
into the setup-method of my custom UpdateHandler:
config.update(pk, updateHandler -> {
((MyUpdateHandler) updateHandler).setup(progress -> setProgress(progress))
});
from update4j.
from update4j.
Thanks for your detailed explanation...now I got some good understanding...I will try as you explained...
Thanks,
John..
from update4j.
from update4j.
I am in mobile, so I only had a quick look.
Your business application also seems to be some kind of bootstrap application. You already hinted about some advantages of using one delegate to launch another delegate that eventually launches the actual business application. I seem to lack imagination here. Could you please elaborate about this?
from update4j.
from update4j.
Hi,
Thanks for your demo application.
Based on your demo application i have created my custom bootstrap and the downloading of files from server is working with progress bar without any issues.
While launching i am getting the following error
Caused by: java.lang.IllegalArgumentException: Unknown command 'false'.
at org.update4j.util.ArgUtils.parseArgs(ArgUtils.java:57)
at org.update4j.Bootstrap.main(Bootstrap.java:85)
... 7 more
How to pass argument to update4j's Bootstrap class.?
In your demo business application you haven't put any update4j dependency in POM file,
but for me its required for
import org.update4j.LaunchContext;
import org.update4j.SingleInstanceManager;
import org.update4j.service.Launcher;
in JavaFxLauncher class.
As per your document there is no need of update4j's reference in Business application.
Thanks,
John.
from update4j.
from update4j.
from update4j.
Hi,
I have edi.demo.JavaFxLauncher in Business application and
edi.update.demo.bootstrap.JavaFxDelegate in Bootstrap application.
I am running my JavaFXDelegate Bootsrap application and click the Launch button to Launch my business application (edi.demo.JavaFxLauncher).
i have tried
args.add("--delegate=edi.demo.JavaFxLauncher")
Got the following error
edi.demo.JavaFxLauncher not found between providers for org.update4j.service.Delegate, using edi.update.demo.bootstrap.JavaFxDelegate instead.
Exception in thread "Thread-6" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.update4j.service.DefaultLauncher.run(DefaultLauncher.java:61)
at org.update4j.Configuration.lambda$launchImpl$9(Configuration.java:1343)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.update4j.service.DefaultLauncher.run(DefaultLauncher.java:57)
... 2 more
Caused by: java.lang.IllegalStateException: Application launch must not be called more than once
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at javafx.graphics/javafx.application.Application.launch(Unknown Source)
at edi.update.demo.bootstrap.JavaFxDelegate.main(JavaFxDelegate.java:29)
at org.update4j.Bootstrap.start(Bootstrap.java:178)
at org.update4j.Bootstrap.start(Bootstrap.java:167)
at org.update4j.Bootstrap.main(Bootstrap.java:98)
... 7 more
and
args.add("--launcher=edi.demo.JavaFxLauncher");
Got the following error
Exception in thread "Thread-6" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.update4j.service.DefaultLauncher.run(DefaultLauncher.java:61)
at org.update4j.Configuration.lambda$launchImpl$9(Configuration.java:1343)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.update4j.service.DefaultLauncher.run(DefaultLauncher.java:57)
... 2 more
Caused by: java.lang.IllegalStateException: Application launch must not be called more than once
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at javafx.graphics/javafx.application.Application.launch(Unknown Source)
at edi.update.demo.bootstrap.JavaFxDelegate.main(JavaFxDelegate.java:29)
at org.update4j.Bootstrap.start(Bootstrap.java:178)
at org.update4j.Bootstrap.start(Bootstrap.java:167)
at org.update4j.Bootstrap.main(Bootstrap.java:98)
... 7 more
How to pass control to JavaFXLauncher(My business application)
Thanks,
John
from update4j.
from update4j.
from update4j.
Hi,
Yes i have copied the demo-business.jar(for my case demo-edi.jar) in the classpath
This XML file does not appear to have any style information associated with it. The document tree is shown below.
But still my Launcher is not loading and the defaultLauncher is called.
Thanks.
John
from update4j.
from update4j.
Yes. I have put edi.demo.JavaFxLauncher in
META-INF/services/org.update4j.service.Launcher
from update4j.
from update4j.
from update4j.
from update4j.
Hi,
Thanks a lot.Finally it worked!
The problem was, as you said the business jar did not contain META-INF/services directory.
Thanks,
John.
from update4j.
from update4j.
Hi,
When i click Launch button the demoedi window is displayed.
I have demo-bootstrap.jar(runnable jar) and demoedi.jar.
Till now i run the JavaFxDelegate.java from eclipse environment manually .
Now i try to run the demo-bootstrap.jar.But the bootstrap window not opening.
Thanks,
John.
from update4j.
from update4j.
Hi,
I'm sorry it was my mistake!!
I start the framework by the following commnd
java -cp * org.update4j.Bootstrap.
Its working.
Thanks,
John.
from update4j.
Hi,
After demo application now i am trying to give my actual deployment folder to update the client,
but while downloading i am getting the following exception.
Package sun.nio.cs.ext conflicts with a package in the boot modulepath.
How to resolve this issue?
Thanks,
John.
from update4j.
from update4j.
Hi,
Thanks for your reply.
After using 'ignoreBootConflict()' in builder ,i'm able to download the latest version from the server.
Now i am trying to update my bootstrap application.
I've created new demobootrap.V.0.2.jar by changing some UI and using version method i increased the version.
The new demobootrap.V.0.2.jar is downloaded.but after restart the Old Bootstrap is called.How to load the new Bootstrap apploication?
Once i delete Old Jar, the new Bootstrap is called.
Thanks,
John.
from update4j.
from update4j.
Make sure that the new bootstrap uses different class names (or better: package names) than the old bootstrap. I really think this should be stressed on the wiki, because this is an easy error to make.
from update4j.
Hi,
This might be the reason for my issue..
I used the same name.i will check with different class name.
Thanks..
from update4j.
from update4j.
Yes...Please add it to the documentation..it would be helpful for others...
from update4j.
Hi,
I tried with the different class name.but same result.
I have 2 jar files(demo-bootstrap.4.0.0.jar and demo-bootstrap.5.0.0.jar)
demo-bootstrap.4.0.0.jar contains class with the name edi.update.demo.bootstrap.JavaFxDelegate with version 2000 and
corresponding entry in META-INF/services
edi.update.demo.bootstrap.JavaFxDelegate in org.update4j.service.Delegate.
demo-bootstrap.5.0.0.jar contains class with the name edi.update.demo.bootstrap.EDIDelegate with version 3000 and
corresponding entry in META-INF/services
edi.update.demo.bootstrap.EDIDelegate in org.update4j.service.Delegate.
when i start the framework with java -cp * org.update4j.Bootstrap, the older version is called
edi.update.demo.bootstrap.JavaFxDelegate(demo-bootstrap.4.0.0.jar)
After deleting demo-bootstrap.4.0.0.jar,edi.update.demo.bootstrap.EDIDelegate is called (demo-bootstrap.5.0.0.jar)
Even if i pass the argument as --delegate=edi.update.demo.bootstrap.EDIDelegate,the lower version is called edi.update.demo.bootstrap.JavaFxDelegate.
What may be the reason for my issue?
Thanks,
John.
from update4j.
from update4j.
Hi,
After changing the package name also i'm getting the same issue.
Please let me know if you have any solution to this.
I will also try some alternatives.
Thanks,
John.
from update4j.
Hi,
Sorry it was my mistake!!
Now with different package name i'm able to delegate to the latest version.
from update4j.
Hi,
With you help i am able to to auto updater for my application.
To update the bootstraper application i need to change the file name every time.
Is it possible to have the same file name.
For example
i should always want demo-bootstrap.jar
Is there any way to achieve this?
Thanks,
John.
from update4j.
from update4j.
Hi,
With your help i have finished my Job.
And the final Step.
While creating config file i am using streamDirectory method of FileMetaData,i would like to exclude some sub folders.
Is it possible to exclude files or folders when i use streamDirectory?
Thanks,
John.
from update4j.
from update4j.
Hi,
I am able to filter the files like below
.filter(r->!r.getSource().toString().contains("cert"))
This also excludes the files which contains cert
But i want to exclude only the subfolder names cert.
How to use properly to exclude folder "cert"?
Thanks,
John
from update4j.
from update4j.
Thanks,
Its so easy,
But i thought of checking isDirectory or not?
Thanks a lot.
from update4j.
from update4j.
Hi,
Now i am able to update Update4j,Bootstrap and my Business application.
The only issue is that i have update4j-1.3.3.jar and update4j-1.4.0.jar in my folder.
Is there any option to delete update4j older version automatically?
Thanks,
John.
from update4j.
from update4j.
Hi,
I have a doubt regarding the client installation path.
Currently the basepath is configured in config.xml.
But in realtime the user may install my application of their own path.Is there any way to check the client installion path instead of getting the static path from config file?
Thanks,
John.
from update4j.
${user.dir} (the working directory) is probably the next best thing. Under Windows, the installation directory is usually also the working directory, although this is not guaranteed and the user can change that.
from update4j.
from update4j.
Related Issues (20)
- Permission Issue: Default Bootstrap Archive Location HOT 9
- Updating app's JDK with update4j HOT 5
- Make update.zip path confgurable HOT 1
- Deletion of files not present in config HOT 8
- getOldFiles takes a long time (too long?) HOT 22
- Basic issue of understanding HOT 25
- Working in offline mode with --local and --syncLocal HOT 3
- Communication between bootstrap and business application HOT 4
- config.update does not download anything and just stop the programs HOT 2
- Headless Setup with NGINX Basic Auth HOT 13
- proposal HOT 1
- NoSuchFileException reserved/config when there is nothing to update HOT 3
- Demo App doesn't run on Windows 11 and Java 19 HOT 4
- Connect/read timeouts too short on URLConnection HOT 1
- Propagating business applications' exit code through Bootstrap HOT 5
- Error running an SWT application HOT 8
- Support multiple architectures HOT 19
- Exception when download files. HOT 2
- Relative path in basePath? HOT 3
- Size of file does not match size in configuration HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from update4j.