How to create javaFX jar from a gradle project written in Kotlin - javafx

So I've found myself in a rabbit hole...
I recently started learning javaFX and have made some apps here and there, well I've now run into a problem on how do I actually build them into a jar?
I use gradle to setup my projects, and run it through gradles application run
basically this video right here:
https://www.youtube.com/watch?v=nKIMGH0l3Wo
The same guy that made that video also made a video about how to package it (https://www.youtube.com/watch?v=dLH-HjiCtaI). Although this doesn't work because I used kotlin to program my apps, and it uses jlink.
I've looked up a bunch of tutorials and guides, but they all talk about using some sort of packager like jlink.
I found a tutorial that builds an artifact which includes the resource folder, which was the closest I found to working, although the application doesn't run (Error: JavaFX runtime components are missing, and are required to run this application).
So is there a way I can build a jar file? Or did I make a mistake using Kotlin?
Thanks!

Luckily I manager to find some work arounds, you can use gradle and kotlin, but your main class can't inherit from javafx.application.Application. Rather you have your main class call the main function of your main application class, that was a lot of mains, but essentially just this
class Main {
companion object {
#JvmStatic
fun main(args: Array<String>) {
MainApplication().main(args)
}
}
}
(The solution I found)
https://stackoverflow.com/a/52631238/16655016

Related

what is the equivalent concept in apache royale for flexmdi.swc , flexlib.swc

When I am migrating the flex to royale application , i am unable to implement the concept MDIWindow Concept in royale.
I am able to find in Visual Studio Code IDE the implementation
//Generated from: C:\RemoteObjectAMFTest\external\flexlib.swc
package flexlib.mdi.containers
public class MDIWindow extends mx.containers.Panel
but not able to find at compile time.
could you please help to compile MDIWindow successfully in royale?
col: 9 Warning: Definition flexlib.containers.MDIWindow could not be found.
import flexmdi.containers.MDIWindow; or flexlib.containers.MDIWindow
As far as I know, MDIWindow has not been ported to Royale. Your best bet might be to decide on the features you actually need for your app and implement those parts yourself. Hope this helps.

Getting image from Class Library

I am doing a refactor of my Xamarin project, in which I want to build nuget-packages for my platform specific projects.
And since you can't make your "App.Droid", "App.iOS" and "App.UWP" into nugets I am using class libraries for this.
My problem is when I put my images (ordinary *.png-files) in my UWP-class library it won't work. It is working in both iOS and Android.
So my question is if anyone knows if this is possible, and if so how?
My current setup is as follows:
My UWP-project is named "App.UWP". This is the project i build and the project has the "App.xaml" and "MainPage.xaml".
I then created a "Class library (Universal Windows)" named "Company.Mobile.Core.UWP".
My "App.UWP" is referencing "Company.Mobile.Core.UWP".
I know I have a working connection between the two. My Custom renderers are in the "Company.Mobile.Core.UWP"-project and not in "App.UWP" and is working fine.
Cheers,
Tobias

What is __meteor_bootstrap__?

I am just starting with Meteor and working on an existing project. I am running into an issue with one of the packages(observatory-apollo) that's has the following line:
__meteor_bootstrap__.app.use Observatory.logger #TLog.useragent
It is complaining that __meteor_bootstrap__.app is undefined.
What is __meteor_boostrap__ exactly? I can't seem to find a description of what it is but from threads, people seem to know how to use it. I can only see it defined in boot.js, but it doesn't really tell me much...
Meteor uses connect npm module under the hood for various reasons, to serve static files, for example. __meteor_bootstrap__.app was the reference to connect app instance.
Before it was __meteor_bootstrap__.app but it changed couple of releases ago and became WebApp.connectHandlers object and is part of WebApp package.
WebApp is a standard package of Meteor, core package for building webapps. You don't usually need to add explicitly as it is a dependency of standard-app-packages.
Example of usage the connectHandlers is to inject connect middlewares in the same way as you would use any connect middleware (or some express middlewares, express is built on top of connect):
WebApp.connectHandlers
.use(connect.query())
.use(this._config.requestParser(bodyParser))
You can look at meteor-router Atmosphere package and take it as an example: https://github.com/tmeasday/meteor-router/blob/master/lib/router_server.js
More about connect: https://npmjs.org/package/connect

MvvmCross MvxApplication class overriding for different platforms. (Plus, encryption)

I've got two questions here. The first one is just specific and another one is more general, but is a source of the first one.
So, my specific problem: I want to use Encryption (actually, Hashing) algorithms with using System.Security.Cryptography namespace (for instance, SHA256Managed class).
I found out that (happily) Xamarin has implemented those in System.dll.
But it is not portable and obviously can not be used from Core application directly.
But I've also found another great project -- PclContrib -- which allows you to do that. But, unfortunately, they don't have the implementation for Touch and Android. (However, that still works great for Desktop (Web) and Windows Phone, plus, still can be included into Core (as it uses portable project)).
Anyway, to solve that nicely, I've decided to create some base class for the encryption methods and then override core methods which require the custom dll (for any custom system).
The way I did it (at least, trying to do) was:
Defining virtual method in Core App base class:
public virtual IEncryptionProvider CreateEncryptionProvider()
Overriding Core App class in Touch project with overriding CreateEncryptionProvider (which creates an instance of TouchEncryptionProvider class instance).
Core:
public class App : MvxApplication
Touch:
public class AppTouch : App
Launching it in Touch setup.cs:
protected override Cirrious.MvvmCross.ViewModels.IMvxApplication CreateApp (
{
return new AppTouch();
}
But, that does not work for me. On startup I've got this exception message in log:
"Exception masked KeyNotFoundException: Could not find view for Mynamespace.Etc.LoginViewModel", which works fine when I do new App() instead. I am not sure if that message shows actual problem (as before it was saying the same even that was a problem with some third-party dll, unrelated to views at all). But speaking shortly, that's just a primitive inheritance of App : MvxApplication, but placed not in Core but Touch project.
So, does it requeire some more custom initialization for such situations or do I miss something else?
And, actually, more general question is how should I build such Multiplatform approaches? Actually, now I've got similar problem with HttpUtility.UrlEncode, which I would want to use in my Core project.
What is the MvvmCross "philosophy" to handle such situations?
Thank you.
For the 'viewmodel not found' problem, this is caused because mvvmcross by default only looks for viewmodels in the Assembly containing your app.
If you want it to look in other assemblies, override ViewModelAssemblies in Setup.cs - see how this done in, for example, MvvmCross - structuring shared View Models and Views
For general multplatform approach, please read questions and answers like:
Platform-specific IoC in MVVMCross
Instantiation of ViewModels and Service classes
Please also remember you don't have to use PCLs - if you prefer to use file-linking between multiple platform-specific core projects, then you can of course use this approach.
Finally, please also try to ask one question per question - I find it makes stackoverflow work better for users and with search engines too. If you need to link questions, then you can just add a hyperlink reference - stackoverflow then marks them as related.

Webactivator doesn't run on IIS 7

I have several web applications that make use of packages using WebActivator. On my local machine with IIS 7.5 Express, everything works fine whether I test in Release or Debug configurations. However, on my production machine with IIS 7.5, WebActivator doesn't actually run, so all the modules fail to load and I have to add the code back into the Global.asax.cs file.
I'm stumped as to where to even begin looking - Googled and searched StackOverflow but haven't ran into anyone having similar issues. Is there anything explicit that needs to be configured to allow it to run?
Edit - Added quick sample of activator that logs to Windows. The function contents, when added to the Global.asax.cs file runs fine on the production server, but never logs from the activator.
using System.Web.Mvc;
using System;
[assembly: WebActivator.PreApplicationStartMethod(typeof(Admin.App_Start.WebActivatorTestStart), "Start")]
namespace Admin.App_Start
{
public static class WebActivatorTestStart {
public static void Start() {
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.Source = ".NET Runtime";
log.WriteEntry("WebActivator Start", System.Diagnostics.EventLogEntryType.Information);
}
}
}
Well, I can't say for sure what I did to fix things, but it's working now.
A bit of history - I manage a number different large applications all using some common libraries. I have my common web library and that's where I used to have the IOC setup with Ninject and WebActivator. This base library had the App_Start folder in it. Maybe this was the reason? Dunno. Never got WebActivator to work with this setup so I just used the NinjectHttpApplication to handle registration and startup stuff. However, the base library still had a dependency on WebActivator (just no App_Start folder).
So now I'm working on refactoring some of the applications and the base libraries - clean up a bunch of code smell from the past few months. One step was to move all the IoC up to the actual web application - make the base libraries less monolithic. The base library no longer has any dependency on WebActivator.
And now it works. There also half a hundred other small changes I've made to the base library, so I apologize to others for not being more systematic about it.

Resources