I am building a JavaFX application in Intellij that will be built and distributed with an .exe installer and will be ran as an exe Application. I have been trying to find a way to allow for remote updates, but I have only found resources that update a jar file by using another jar file hosted on a website. Is there a way to allow for remote updates to a exe JavaFX application? I have though about using update4J, but sadly I have no idea how to implement it, use it, or if it will even work with exe applications. I have tried to use FXLauncher, but I am not able to use JavaFX with maven as an error occurs whenever I try adding maven framework to the project.
I am the developer of update4j.
The framework used to be complex and hard to use, but the last release (1.2.2 at time of writing) significantly simplified things leaving only one pain point, namely, generating a configuration.
So for starters, launch the framework using it's own main method:
# on classpath
$ java -jar update4j-1.2.2.jar
# on modulepath
$ java -p update4j-1.2.2.jar -m org.update4j
And read the output.
Creating the configuration is done using a builder, I'm still documenting it but the class javadoc for Configuration is quite complete.
Related
I'm developing simple Java application in Eclipse Oxygen. I would like to ask Eclipse to copy binary files to testing machine automatically when it builds. How to achieve that? How to run script on remote Linux machine that restarts application when binary is copied?
UPD
Since Eclipse builds project very often I would like to have Deploy functionality according to request. How to achieve this option?
Look at the 'Builders' page of the project 'Properties'.
You can add an 'Ant' script or a program to be run when the project is built along with the other builders.
Builders normally run quite a lot so you may want to turn 'Build automatically' off.
It is also possible to write an Eclipse plugin which contributes additional builder types - but that is more work.
I have created a simple springboot application with inbuild tomcat which works fine when I am running it as JAVA Application in Eclipse. I tried to export this as a WAR file and tried to run it in Windows command line and also in UNIX box. I tried to execute it like below,
java -jar C:\Users\Iam\Documents\SpringHelloWorld.war main.java.com.controller.SpringBootWebApplication
Error: An unexpected error occurred while trying to open file C:\Users\Iam\Documents\SpringHelloWorld.war
java -cp C:\Users\Iam\Documents\SpringHelloWorld.war main.java.com.controller.SpringBootWebApplication
Error: Could not find or load main class main.java.com.controller.SpringBootWebApplication
I just export it as a WAR file, should i need to define anything before exporting it as WAR in Springboot ( note: i am not using maven or gradle )
Below is my project structure :
enter image description here
Probably it is possible to do this without Maven/Gradle, but I would never take this approach.
Even considering the best case, you will end up re-creating what others have created in the Spring Boot parento pom.xml or in his Gradle equivalent, so why you would waste a lot of time recreating what is already created by someone else? If you really want to know how the war is created, then take a look in Spring Boot parent pom, but you should limit your work to wrap what is ready for production in order to compose your solution.
Also consider that Maven and Gradle are constantly developed and updated, along everything belongs to their ecosystems. If you plan to replace them, then you should be prepared to mantain and develop alone your own build platform, which is a non-trivial effort.
Better include Maven or Gradle, you'll be more productive.
As a novice to the world of Java programming, this question has always boggled my mind. I first believed that all Java files were compacted into applets and then ran, but I soon realized that this isn't always the case. Could someone explain to me how we actually interweave our Java applications into a real product of everyday life?
TL;DR: How do we implement our code for practical usage?
It depends on the application. There are many options depending on how you want your users to use your app. Usually it's packaged as a jar or a specialized jar (war, ear).
In theory, you could zip the raw directory structure with your .class files in it and provide a shell script/instructions that run the java command for the user. I don't recommend this because it's kind of unprofessional and requires you to maintain a shell script for each OS you want to be able to run the program on.
Jar files are used to package libraries but you can also have a manifest file in it that says, "When someone double clicks/executes this, run this class". That class can start up a GUI or be a headless task that responds to the parameters, etc.
You can have applets, like you said. These programs are run in the user's browser.
You can have a war file, which is a way to package a web application. You give this to a web server and it knows how to deploy it so that you can visit the web pages. An example web server/container is tomcat or jetty.
You can have an ear file which can contain other war files inside it. This is used for applications that need other parts of the javaee functionality (ejbs, jms queues, etc.). An example of an application server is jboss or glassfish.
There's also java web start apps. These are apps you can run by visiting a webpage, but they get downloaded to your computer and run on the user's computer (instead of on the server's backend, like in a war/ear).
There's also javafx. I don't know anything about that though. By skimming the FAQ, it appears to be Java's answer to Adobe's Flex. You configure UI components with an xml configuration. I'm not sure what format JavaFX apps use, but it does say, "Deploy on the desktop or in the browser".
As Sotirios Delimanolis mentioned in a comment below, you can build these files with build systems like Ant or Maven. You can also build them "by hand" with the tools that come with the java/javaee sdk. For example, you should have a jar command in your path if you installed the sdk. Here are some details of these build systems:
Maven
High level (you tell it what to build, not how to build it)
Much more than just a build system. It also has dependency management, etc.
Opinionated (it uses convention over configuration, each config file generates 1 artifact, etc.)
Ant
Low level (you tell it how to build things)
Flexible
Config files can do whatever you want, build as many artifacts as you want
Easy to learn
SDK tools
Always up to date. EG: Very rarely, maven/ant may not be able to set a configuration option
Difficult to remember commands
Very low level
By itself, not repeatable (EG: unless you build a script, you will have to type the jar command yourself each time)
Applets never really caught on and are very rarely used nowadays.
Simple applications can be deployed as "executable" JAR files , which are basically ZIP archives with additional metadata that tells the JVM which class contains the main method to run. They can be run on the command line using the -jar option, or in most desktop environments by double-clicking (this requires a JVM to be installed as well).
Desktop applications can be deployed via Java Web Start or installers like IzPack or Install4J, but Java desktop applications are not very common either.
Most Java software nowadays runs only on servers (web servers or app servers). They are typically deployed as WAR or EAR files, which are also ZIP archives containing classes and other resources. These applications then run inside a server component following the Servlet or EJB standards.
If the application is mean to run on a client, it is packaged as an executable JAR, then further packaged as an Application Bundle (Mac), maybe wrapped in an exe (Windows), or paired with an executable script that will launch the JAR and set any required VM arguments.
If it is part of a web application, then it will be packaged as a WAR or EAR and placed into the appropriate location on the web server.
If it is simply a library, then it is usually packaged as a JAR (non-executable) and distributed as such for integration into larger projects.
applets and then ran, but I soon realized that this isn't always the case
Actually, applets are rare nowadays and their use is discouraged.
Create an executable jar, a war which is dropped into a web server or a library that is used by another project that is one of the previous two.
Am trying to execute a complete Jython project using java eclipse 3.4.. I have configured Jython environment in my eclipse..I went through certain tutorials which described about Building a factory.. But i guess that method can be used to execute applications that are specific to a particular Jython module.. What I exactly need is::
To run the entire Jython project as a java application, by using the .class file created in the Jython project..
Not sure if this is feasible.. Suggestions please..
One Java class with an embedded PythonInterpreter is capable of kicking off an entire Jython application. May need to play around with setting the appropriate python.home and library paths, look in the PyServletInitializer and PyFilter for examples of how this is done.
Another option is use PyDev and just run a Jython script to start the application, bypassing the need for a Java application all together.
I've finally managed to create a Netbeans project out of an old standalone (not Web-) Java application which consisted only out of single .java sources. Now I have basically two questions regarding Netbeans Subversion interaction and application deployment:
Do you check in all the Netbeans project files into the repository, normally?
If I build the project using Netbeans (or ant) I get a .jar file and some additional jar libraries. In order for the app to run properly on the server, some additional config files and directories (log/ for example) are needed. The application itself is a J2SE application (no frameworks) which runs from the command line on a Linux platform. How would you deploy and install such an application? It would also be nice if I could see what version of app is currently installed (maybe by appending the version number to the installed app path).
Thanks for any tips.
No, not usually. Anything specific to NetBeans (or Eclipse, IntteliJ, etc), I don't check in; try to make it build from the command line with your ant script and produce exactly what you want. The build.xml is something that can be used for other IDEs, or in use with Anthill or CruiseControl for automated builds/continuous integration, so that should be checked in. Check in what is needed to produce/create your artifacts.
You don't specify what type of server, or what exact type of application. Some apps are deployed via JNLP/WebStart to be downloaded by multiple users, and have different rules than something deployed standalone for one user on a server to run with no GUI as a monitoring application. I cannot help you more with that unless you can give some more details about your application, the server environment, etc.
Regarding the config files, how do you access those? Are they static and never going to change (something you can load using a ResourceBundle)? ? You can add them to the jar file to look them up in the ResourceBundle, but it all depends on what you are doing there. If they have to be outside the jar file for modification without recompiling, have them copied with an installer script.
As for directories, must they already exist? Or does the application check for their existence, and create them if necessary? If the app can create them if absent, you have no need to create them. If they need to be there, you could make it part of the install script to create those folders before the jar files are installed.
Version number could be as simple as adding an about box somewhere in the app, and looking up the version string in a config/properties file. It has to be maintained, but at least you would be able to access something that would let you know you have deployed build 9876.5.4.321 (or whatever version numbering scheme you use).
Ideally, you should not tie down your application sources and config to a particular IDE.
Questionwise,
I suggest you do not. Keep you repository structure independent of the IDE
You might have to change your application so that it's structure is very generic and can be edited in any IDE.
Is this a web app? A standalone Java app? If you clarify these, it would be easier to answer your query.
We don't check in the /build or the /dist directories.
We tend to use this structure for our Netbeans projects in SVN:
/project1/
/trunk
/tags/
/1.0
/1.1
/binaries/
/1.0
/1.1
When a change is need we check out the netbeans project from trunk/ and make changes to it and check it back in. Once a release of the project is needed we do an SVN copy of the netbeans project files to the next tag version. We also take a copy of the deployable (JAR or WAR) and place it in the version directory under binaries along with any dependencies and config files.
By doing this we have a clean, versioned deployable that is separate from the source. Are deployables are version in the name - project1-1.0.jar, project1-1.1jar and so on.
I disagree with talonx about keeping your source non-IDE specific - by not storing IDE files in SVN along with you source you are adding extra complication to the checkout, change, checkin, deploy cycle. If you store the IDE project files in SVN you can simply check out the project, fire up the IDE and hit build. You don't have to go through the steps of setting up a new project in the IDE, including the files you SVNed, setting up dependencies etc. It saves time and means all developers are working with the same setup, which reduces errors and discrepancies. The last thing you want is for a developer to check out a project to make a small bug fix and have to spend time having to find dependencies and set stuff up.
To answer question #2 -- who's your consumer for this app?
If it's an internal app and only you (or other developers) are going to be deploying it, then what you have is perfectly all right. Throw in a README file explaining the required directories.
If you're sending it out to a client to install, that's a different question, and you should use an installer. There are a few installers out there that wrap an ant script and your resources, which is a nice approach particularly if you don't need the GUI... just write a simple ant script to put everything in the right place.
Version number is up to you -- naming the JARs isn't a bad idea. I also have a habit of printing out the version number on startup, which can come in handy.