Import JavaFX 11 Maven project to Eclipse - java

Is there any way to configure a Maven-based JavaFX project so that I can import the project in (vanilla) Eclipse and debug it like other Java/Maven projects?
I am used to distribute projects with Maven and typically, everyone in the team (as well as the CI server) can rely on Maven for packing, testing, running it etc.
For debugging, however, the project can be imported to Eclipse and started via a main class (as opposed to Eclipse's maven plugin).
A nice example is Spring-Boot. After importing such a project, I can just run or debug the main class.
For JavaFX 11 however, this seems to work to write a pom.xml that configures all necessary dependencies, but when I import such a project to Eclipse (as Maven project), it does not configure it to the point where I could run its main class. I can run "Debug as..Maven build..", but not via the main class. I understand that it depends on platform-specific dependencies, but if it can be started vie Maven, it should be possible to start it from Eclipse without configuring Eclipse, can't it?

I've been using Eclipse with a Maven project in exactly the way you would like to use it all the time with JFX11. It works without problems if you tweak the launch configuration correctly. Details can be found here: https://openjfx.io/openjfx-docs/
By far the easiest way to get this running is to ignore the module system and make sure that all libraries (also the JFX libraries) end up on the classpath and not the module path (which is the default if you do not have any module-info.java in your project). Then add a single line of code like this to the file with you main class.
class MyJFX11AppLauncher {public static void main(String[] args) {MyJFX11App.main(args);}}
In the Eclipse launch configuration make sure to launch your app via this new launcher class. That does the trick to run the JavaFX app without a whole flood of runtime options which you would need otherwise to get all this working. (See docs above.)
WARNING! This is not the official way to launch a JavaFX app but it works for me and I have never noticed any problem with it. Use at your own risk!

Related

Can't run very simple Java application in Eclipse IDE for Enterprise Java and Web Developers , but can run it in Eclipse IDE for Java Developers

I get a java.lang.ClassNotFoundException for the class that I'm trying to run. The class itself has nothing but a static main function which prints test.
I created the project in the exact same way in Eclipse IDE for Java developers, where it does run. Then I looked through project properties to see if anything was different. I also checked the run configuration. Everything seems the same.
I have cleaned the project. It is a gradle project and I have also tried running the clean task and the CleanEclipse task. The gradle build task runs successfully.
I have tried creating a default Java project without gradle and it gives me the same problem.
I do have a project using gretty that is functioning properly, but it has a dedicated gradle runApp task.
I could just try and reinstall Eclipse IDE for Enterprise Java and Web Developers again, but then I'll never know what the problem was.

Lookup source of application internal impl without having them as dependancies to our project in eclipse

I’m developing plugin for a web application (It’s with Liferay, but it does apply to many other case). My project has dependency on the public interface lib from the main application, but obviously not on its internal implementation.
When debugging or simply trying to understand what a badly documented method does, I’d like to be able to navigate to the application internal. I can actually import the whole application project and add an eclipse project reference to it. This way of doing it requires Eclipse to build and validate the whole app project and slow down a lot of thing in eclipse.
What I would like to do is to be able to reference those source in a way similar to the direct project dependencies. Is there some way to do something like this with eclipse?
If you don't have an artifact for the impl source (or you're not willing to add a dependency on it even temporarily), then the only option I can think of is to import it as a project into Eclipse and turn off the auto build functionality. But since that's a workspace-wide option, doing so will also disable automatic building of your own project - you'd have to manually build your project when operating in this mode.
To avoid that trade-off, you could create a new workspace in which to import the main application impl and disable auto-build in just that workspace. Then you'd have to switch back and forth between your project workspace and the application impl workspace, but that might be acceptable to you.
Having said that, I'm not sure why it's all really necessary. Importing and building a large application can take some time, but once it's done it should not have any impact on Eclipse's operation as long as you don't touch any of the files in that application project.

Breakpoint not registered in eclipse in maven multi-module web application

I'm currently working with a maven multi-module application in eclipse.
In some classes I can set breakpoints, and after starting tomcat (via eclipse) in debug mode, they get registered (meaning, a small tick icon is displayed next to the blue round breakpoint icon), and the debugger stops there.
In some other classes, the breakpoint is not registered, and the debugger doesn't stop there.
Why? And what's the mechanism underneath, like, are breakpoints only registered for classes that were already loaded? Or how does that work?
Update:
Using Eclipse 4.5.2 under Linux, Tomcat started under Oracle Java 1.6.0_45
It is hard to provide answer for such generic issue... however here are some hints. Let's assume the structure of your multi-module is following:
foo-project (parent, POM packaging)
foo-library (JAR packaging)
foo-webapp (WAR packaging, depends on foo-library)
Now from Eclipse's point of view, you have 3 "separate" projects. You are running your foo-webapp on Tomcat and that is what you are debugging. If you place breakpoint inside foo-library that is a different project, potentially unconnected to foo-webapp.
So what you need to do is to make sure your foo-webapp has project dependency on foo-library so that Eclipse knows when you run one project, the other is used as well. This is usually done manually automatically but by the m2e plugin. So I hope you are using that and not the obsolete maven-eclipse-plugin. Next thing you should make sure is that your dependency is correctly defined in the pom.xml... if the required version is not the same as the version of the library, m2e might link you JAR and not the project itself. And last not least you need to Enable Workspace Resolution for m2e to actually start connecting projects.
If you are sure all the things above are correct in your case, you might try to update the project according to the POM via Right click on project > Maven > Update Project....
When everything is in place you should see your project dependencies under Maven Dependencies in your Java Build Path tab.

Eclipse and maven dependency during development

I do have own developed Java library (MyLib), which I later publish on private Maven repository and have it as Maven dependency in another webapp project (MyWebapp). If I have both projects - MyLib and MyWebapp at the same time opened in Eclipse - is there a way somehow to configure MyWebapp so, that local changes made to MyLib would be directly added to MyWebapp while building/deploying it? The issue is that during development it is not really comfortable always to make some changes in MyLib, make a build, deploy to Maven repository and then make a MyWebapp build, deploy it and only then I can see how the changes are affecting the webapp project...
I would like to reduce the overhead while developing and willing to see how changes are working out. Of course when it comes to real releases the above described flow does really make sense and works great.
Thanks!
There is no simple "just tick this option" solution, unfortunately. You can chose between these options:
Convert MyLib into a Maven module and add it to the sources of MyWebapp. This, of course, will make it harder later to reuse the library alone.
Stop deploying the application. If you look at the classpath in Eclipse, m2e should have added the dependency as a project from the workspace (instead of depending on the JAR in the repository). If not: There is an option for this.
The next step is to create another project which depends on Jetty and MyWebapp. Create a Java application in there (i.e. a file with main()) which creates a Jetty server and configure it to use the current classpath. That way, you can start the webapp just like any other Java application without deploying - Jetty will simply load classes from the classpath that m2e assembled.

cannot run osgi bundles outside eclipse

I am making my firsts steps using osgi and I have a problem with a bundle I created.
I developed 3 bundles in eclipse (they are plugin projects). When I run my bundles inside eclipse using a new and empty target, they work very nice.
Then I tried to export them and run them without eclipse I ran with problems. I created a jar file for each one of them (using export ->deployable plugin) and then I install them in a running equinox container (v3.7.1, from eclipse's plugin directory) and I got a lot of ClassNotFoundExceptions for RuntimeErrorException
this looks like a classpath issue. I think I am not exporting the bundle correctly, but I am not sure.
The problem only happens with 2 of the bundles, which use additional libraries
how can I do it correctly?
In case you need it, this is the full stack
Taking one of the exceptions for example: NoClassDefFoundError on javax.management.RuntimeErrorException.
Did you import the package javax.management in your bundle?
See the following page from the OSGi Community Wiki, it seems directly relevant to your problem: http://wiki.osgi.org/wiki/Why_does_Eclipse_find_javax.swing_but_not_Felix%3F

Categories

Resources