JavaFX program to JAR, been trying to do this for days - github

Can anyone help me convert this javaFX application into an actual application using JAR, becuase ive been trying to convert it to a JAR for days and it just comes up with error after error. I just want to make an exe but i know how to do that, the JAR ive been trying to make and it makes it, but it never runs, just errors, a million of them.
Here's my github repo https://github.com/Amarnath-someperson/JavaFX-Physics-App with the code in JavaFX-Physics-App/PhysicsApp/src/main/java/com/example/physicsapp/

Creating jars for JavaFX apps is not well supported and you just should not do it. Instead look here https://stackoverflow.com/tags/javafx/info in the Packaging section and create a real app bundle and installer.

I recommend taking a look at this Github repo: https://github.com/wiverson/maven-jpackage-template
It contains a working projekt using Maven, JavaFX 17 and Java 17. Running maven install creates an installer and a runnable exe file. As soon as you get it running, making the necessary changes for your project should not be too difficult.
Asking others to do the complete work for you probably is a bit too much in my opinion. You will need to get a basic understanding of how the packaging works to maintain your project anyway, so I hope this is enough to get you started.
Packaging your application as jar is only useful up to Java(FX) 8, since JavaFX is not included in most JREs after that. So, while it is easy to create the jar, non-developers won't be able to run it.

Related

Building JUnit 5 from Source in eclipse on Windows

I'm currently using JUnit 5.1, but I want to switch to JUnit 5.5 (at least 5.4) to use new features of that version (mainly the #Order annotation), but I'm really struggling to properly set it up.
Unfortunately I cannot simply switch to a newer eclipse version, because I'm tied a specific version we use at my workplace.
As there is no JAR-download, i've tried to build it from source. The only guidelines concerning this are saying to build it with Gradle, but I don't understand how to do this.
What I tried so far:
- downloaded the repository as an archive (zip) and imported it to eclipse, which resulted in multiple projects and <1.000 errors
- imported the repository into eclipse (via import wizard), but failed to find a way to make a build from it
I was able to run some test with JUnit 5.4 features, but i achieved this by downloading different modules as JARs from some maven-repository I found in a JUnit issue on github and including them as external JARs into the classpath. This was very tedious because of the number of different JARs & the way they were organized in the repository folders.
To me this feels like a workaround, as I still have no idea how to solve the initial problem of building JUnit from source.
I'm quite new to eclipse and have a basic understanding of what Gradle is, but I've never used it so far.
I don't expect a detailed step-by-step guide on how to achieve this (although I wouldn't complain ;) ), but I'd really appreciate it, if you could give me an outline of how building from source is done in general and maybe additional references for me to read about certain steps (e.g. setting up gradle).

How to import then build multiples local jars (~100) into a maven project

First of all, sorry if my question seems to be duplicated but I have thoroughly search during hours and hours a solution without any success...
This is my current context :
I have developped a huge talend job which uses many others jobs
I have built my talend job as a standalone jar. That resulted in a zip file containing a lot of others jars (around 100). All of those jars are needed for my talend job to work. Those are secondary jobs or libraries, etc.
Then I have made a spring-boot java application (using maven...) that can run my talend job among others things.
In order to do that, I had to import every jars into my project => i.e build path. Those 100+ jars are all visible inside the "referenced libraries" folder.
When I run my app through Eclipse, everything is working well but now what I need is to build this app as a jar, or something I can run on another machine/server.
I don't know anything about maven, but if I understand well, I need to use the command maven-install in order to build my project... The problem is the command throw me errors because it doesn't find all my libraries.
I found many solutions that says to create a local repository, to use maven-install for each jar, or maven-deploy for each jar, then add dependencies into my pom file for each jar...
As you could understand, that's not a good solution for me and my 100+ jars...
I heard about nexus or something like that, but I am the only one person working on this project and this solution seems to be interresting when a whole team is working on the same project.
So, if any of you knows how I can manage that, I would be very grateful.
Thanks.

Running jersey 2 server using jetty 9

I have been struggling for many hours on trying to deploy a simple HelloWorld webservice written in java on a windows 7 (later ill need on linux) pc.
Most of the examples I found (from general places, and others questetions on stackoverflow) didn't work or used deprecated versions of jersey and other librarys.
My goal, is to write a webservice in java, where coding it should be easy and so does deploying it. It doesn't need to suuport anything special regarding the amount of request running and performance (my requirements are minimum)
Frommy research, I have come to believe the use of jersey with embeded netty web service should anser what I was looking for (if someone knows better, I would also like to hear about it, tough it isn't my main problem in this questetion but might just be an alternative solution)
I have came across this eaxmple:
jersey2-jetty-example
It gives you a working project with the dependencies needed from maven to run jersey and jetty embedded server (which can be run as a standalone jar which is exactly the kind of easy deploy im looking for)
I cloned the example and got everything running. I had problems importing it to eclipse, so I used the following command on the example folder:
mvn -DoutputDirectory=./lib dependency:copy-dependencies
which will give you a copy of the lib folder of the deps from maven needed,
then I created a java project with this lib folder in the build path and same source code as the sample, and all worked good.
The problem occurs when I try to take this java project and export it as an runnable jar (with the source files included option !).
I can then use java -jar to run the service, but when I try to access it from the browser (same as used in when I run it from eclipse), it never works, im always getting error 404 for the same routes that worked a second ago when running from eclipse. I couldn't figure out whats the source of the problem or what eclipse does differently that makes it behave in a different fashion.
I have found the reason the jar didn't work while in eclipse it did work, it was because of a duplicate jar that I was importing the caused the problem. The jars I got from maven in the git sample had 2 duplicate jars called hamcrest-all and hamcrest-core. removing one of them from the project build path fixed the problem.
If someone can answer the other open ended questetion that I asked, which is if using jersey and jetty like this is the best solution for my requirments I will be happy to hear about it

Build vs Deploy vs Publish (Eclipse IDE)

I'm a newbie to J2ee though not a complete newbie. I'm unable to find a good resource (book or video) that could help me understand what exactly happens when we build, deploy and publish. I have a fair idea though. So my questions are -
Is there a good resource out there that can help me understand these concepts? I've read some books on struts and servlets/jsp but they don't delve into eclipse and how/what it does. The eclipse documentation has been helpful but only slightly.
When we build an application the the java files are converted into the class files and stored in the java build path. What else happens during build? Many people use the term 'library dependencies', what does this mean? Also, when people refer to dependencies do they refer to files like xml and tld?
At what stage (build or run on server) does the container check to see if the dependencies are alright? Say for instance, if the servlet class/name in the web.xml file.
Is it appropriate to say that build is basically compilation while deploying the project and running it is the same as executing it?
Familiarity with the servlet specification would help you (perhaps some older version would be quicker to read like 2.4), but general understanding of what you build and how you do it in Eclipse is what you are after.
The way I see it is that during the build Eclipse creates almost complete version of WAR (or some other archive, if you use EJBs for instance) and by publishing you deploy it to some server (this is practically the same thing although Eclipse might just configure the server to use exploded WAR that it just prepared instead of copying it to some "deploy" dir that you are supposed to do if you work without an IDE).
If you configure your project well, the build can only mean compilation, but if you have more ceremony in it, then some source generation and moving files around might happen too.
To address your second question, library dependencies can be files that reside in WEB-INF/lib for instance. Read the spec to know what should be there and what should not. Eclipse tries to copy there all defined dependencies of your project.

ant deployment issues

i am looking to make our deployments here not suck and i need some help, if you can help me with these few things i owe you beer
right now whenever i make a change thats not to the jsps i need to clean-including-tomcat otherwise my change doesnt take. this is really annoying.
any clues as to what i can change to make it work?
my current build is really simple, just the regular old, javac, war, deploy
one thing that isnt done is that there is no build dir, the project itself contains a web-inf and the javac is done in place, then the war excludes all the .java resources and wars the project.
edit:
I am looking to fix this problem with least amount of effort - so while switching to maven and learning how to use it might solve this problem, but it will create another problem ;)
You've already identified some of the weaknesses, in your current build.
The easiest way that I can suggest to clean it up would be to start with the directory structure.
I highly recommend using the maven directory structure, I would go further to suggest using maven as a build tool instead of ant, however for some folk that remains open for debate.
The maven directory structure has been well thought out, I really like working on projects that use the maven directory structure, because they follow a convention that allows me to save a lot of time, by knowing from previous experience where to find the application components
java source
unit test source
resources etc.
Also by following the convention, the maven plugins work with less configuration required.
Another useful advantage that I get from working on maven based projects is good code metrics, to measure the health of the application. There are various report available as maven plugins, which will give you new insight into your codebase, including:
checkstyle
pmd
findbugs
and more.
Created a build directory where everything got copied before build
Added some flags to not copy over things that rarely change, like images (also to not remove them on clean)
Started using ant-reload task after deploying code
Now i don't need to restart tomcat on every build, and build takes much less time.