Hello everybody! I need some help with something a...
# tornadofx
s
Hello everybody! I need some help with something and I hope someone is willing to. So the past month I've been busy creating a very simple app for a client of mine. It is essentially a simple GUI for them to fill a database with questions and answers and stuff that will be used in a mobile app. Now, this is the first time I used TornadoFX for such a job. It looked very simple and I got the job done pretty nicely. There is a problem tho: I finished the application, but I can't seem to export it in any sort of way. That being a .jar or an installer or anything. I'm using IntelliJ for this and I've tried a few methods, like just building artifacts and creating an installer using The Badass JLink/Runtime Plugin, but none seem to work. I am basically desperate for help at this point, because if this doesn't work I will have to make it from scratch again in something like JavaFX, which I sincerely do not want to do. I hope someone is willing to help me. I'm new to this Slack but I hope you can message me or respond to this. With kind regards, Sergen
b
I can provide a relatively working example (package unfinished). Run console
./gradlew runtimeZip
or run task
runtimeZip
in IDEA
s
Hi @Bogdan! I used parts of your build.gradle.kts to run it. It took a lot of fiddling around but it finally built successfully when I ran ./gradlew runtimeZip. In the image you see what I got in my build folder right now. I am pretty positive the one I need is NcbAdminPcApp-win (NcbAdminPcApp is the name I gave my application), though I still don't know what to do with this. Inside there's 4 folders (bin, conf, legal and lib) and 1 file without file extention (release). Can you help me further? I'd really appreciate it!
b
this is the result of the
runtime
task. task
runtimeZip
- creates an archive based on these files. The archive is located in distributions
the launch is in bin, there we are looking for a script with the name of your file
s
@Bogdan I see ncb-admin-pc-app (again with no file extension) and ncb-admin-pc-app.bat
In a zip file in the distributions folder that is
b
1 - unix* 2- windows
s
So it should start the application if I open the .bat file on Windows?
b
So it should start the application if I open the .bat file on Windows?
yes
In a zip file in the distributions folder that is
clarification, it collects for the platform under which you collect. JavaFX requires native library. Can be modified for all architectures at once
s
Yeh I did try those things and have been on the websites you sent. Still, when I run the .bat file it does not open my app.
b
running in the console?
displays errors
s
How do you run a .bat in the console?
b
I don't even know how to explain it to you. Let's take it simply and run :D. Two options, run through the full path or through the relative. In the second case, you need to go to the folder with the binary. console: name.bat
google: run bat file console
Did I understand correctly that you are using Windows?
s
Yes I am using Windows. When I try to run the batch file however, nothing happens. No errors or anything, just nothing gets printed.
b
in the chat I see that you do not know about the main method, this is the entry point of the program in Kotlin
s
I did know of it, I just didn't know it was necessary. I added it now but I'm not sure what to put in the main class value, it keeps saying it can't find it.
Copy code
tasks.withType<Jar> {
    manifest {
        attributes["Main-Class"] = "main.kotlin.com.kukumavcreations.NcbAdminPcApp"
    }
}
NcbAdminPcApp.kt is the one with the main method
And when I put
Copy code
manifest {
    attributes["Main-Class"] = "com.kukumavcreations.NcbAdminPcApp"
}
I still get the error
Error: Could not find or load main class com.kukumavcreations.NcbAdminPcApp
Caused by: java.lang.NoClassDefFoundError: tornadofx/App
b
name + Kt
show declaration fun main
s
It's simply what you sent
Copy code
fun main() {
    launch<NcbAdminPcApp>()
}
b
Copy code
attributes["Main-Class"] = "com.kukumavcreations.NcbAdminPcAppKt"
if the function is declared in top-level then you need to add the file
Kt
to the name
s
Ok I did that now, but now I still get the following error
Exception in thread "main" java.lang.NoClassDefFoundError: tornadofx/App
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at com.kukumavcreations.NcbAdminPcAppKt.main(NcbAdminPcApp.kt:46)
at com.kukumavcreations.NcbAdminPcAppKt.main(NcbAdminPcApp.kt)
Caused by: java.lang.ClassNotFoundException: <http://tornadofx.App|tornadofx.App>
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 11 more
b
are you running
java -jar
or
bat
file?
for the first, you need to specify the libraries
s
The .jar, I'll try the bat now
The .bat started! That is awesome
b
.jar
is just your classes (files), unless of course you are using the
shadowJar
plugin. Therefore, you also need to specify the classpath.
s
Ah ok understood. Well the .bat works so I think I'm good now. I can't thank you enough bro!! Awesome of you to help me and I thank you for your help!
b
I spent a lot of time on the complete assembly myself. this assembly includes the JVM - this is a fully working application without the need for dependencies
s
That's very nice man! Thank you again for providing it for me ahahah, I'm finally done 😄