I would like to start a Eclipse RCP 3.x application from within Java code. I need to do this because I need to launch the RCP app from within a framework, that needs to be initialized first.
To have access to this other framework (which is SAP NetWeaver Mobile by the way), both applications need to run in the same JVM - therefore I can not call the .exe to start the RCP application. Within RCP I need to access the SAP framework.
Any help would be welcome.
Thanks in advance and best regards, alex
You can take a look at what the .exe does:
eclipse.c
Basically, it starts the VM with this jar: org.eclipse.equinox.launcher_xxx.jar and execute its org.eclipse.equinox.launcher.Main class
Look at the EclipseStarter class. I think you need to get the Equinox framework Jar file and have it be in your classpath to use this. That's called org.eclipse.osgi. If you have a situation where you are providing an API in your Java class to call into classes managed by Eclipses the situation gets considerably more complicated. Make a comment on this if that's the case and I can provide some information there.
Related
I want to convert a jar package or class into a DLL file and inject the DLL into a running Java program through injection. This Java program can't use attach and agent, which makes me a headache. This should work, such as(Thanatos[1.12.2][1.635-v1].dll) this is a DLL that can be injected into minecraft 1.12.2. I was told that it was made by j2d, but I searched all over the search engine and found no relevant knowledge.
Besides the methods mentioned above, is there any other method to inject jar into the running Java program?
Good luck
Of course it is possible to add jars to running programs.
As one example, look how application servers like Apache Tomcat deploy and undeploy applications (see https://tomcat.apache.org/tomcat-9.0-doc/deployer-howto.html).
This is achieved by a clever combination of Classloaders as explained in https://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html
Going through the DLL approach will just create more headache for you.
I am maintaining a Java application developed using Java SWT. This application uses the Eclipse Help System.
I have an Eclipse Help plugin developed and I would like to reuse it.
The current solution packs the help as a "Standalone help" as is described in Help Eclipse documentation. In this way an independent Eclipse Platform Runtime has the Help plugin and my application make API calls from its Help.
(The help works properly). The drawback of this solution is that a complete Eclipse platform is included (and distributed).
I would like to avoid the use of the "independent Eclipse Platform Runtime" and I wonder if it would be possible. I.e. I would like to avoid the distribution of the complete Eclipse platform which is in fact bigger than the application I am maintaining.
A possible solution would be to use Javahelp instead, but Javahelp uses Java Swing and my Application is uses Java SWT.
I’ve created an RCP project that calls the Help plugin.
Would it be possible that my Java application calls to the RCP project and
the RCP project calls to the help without needing any additional action like push a button?
Another problem that I have observed is in order to call help plugin from RCP project, the RCP project needs to show its window. Is possible to avoid this?
All of the solutions I found on stackoverflow suggest wrappers to register java application as windows service. My requirement is totally different. Please don't suggest wrappers for the purpose. The question is very simple I have java executable and I want to register it as windows service.
Phyiscal Path
Service Properties
Unfortunately we don't have backup of previous setup that installed it as windows service at the first place. Do I need some setup program or anything like that.
Not necessarily.
It is difficult to advise you on precisely what you need to do without more information on what you actually still have; e.g. an application installer, application JAR files, wrapper scripts, etc. Alternatively, if you told us what the application was, then maybe we could give you some hints on where to get installers, etc.
However, I can tell you definitely that registering java.exe or javaw.exe directly as a Windows Service will not work. These are not the executables for your Java application. Rather they executables for as Java Virtual Machine that will run your (real) Java application.
It is so easy task in case of Visual Studio. I want same support in Eclipse or anything else.
Well Java doesn't work like that. Java compiles to platform independent bytecode files, not to platform-specific native code. Sure, there are third party tools to generate exe's. However, using them is neither necessary, or desirable:
Why is creating an .exe from a java program not recommended?
(And asking for recommendations on what tools to use to do this is off-topic.)
Finally, if you take an arbitrary Java program and turn it into an ".exe" file, it won't necessarily be immediately registerable as a Windows service. This Q&A talks about turning an ".exe" into a Windows Service.
Create Windows service from executable
However, I can't tell you if the advice given there is appropriate for an ".exe" file created from an arbitrary Java app by some unspecified 3rd-part tool.
My recommendation:
If you are starting from scratch, use a Java Service Launcher / Wrapper.
If not, talk with whoever supplied and/or installed this application in the first place.
If you can't find any information about the application and where it came from, or if the vendor has gone out of business ... you need to urgently look for an alternative.
I would like to run a Java application as a service. Unfortunately, I am limited in that I can't use something like the Java Service Wrapper (which does appear to be an excellent tool).
Is there any way of running an executable JAR, as a service, without relying on external applications? I currently have the service installed, but it fails to start. This is where I am getting stuck and I haven't been able to find anything on Google other than information about the JSW.
There's an LGPL clone of the Java Service Wrapper: http://yajsw.sourceforge.net
BTW, IANAL, but I suspect that JSW people are spreading FUD, and their software can be used to service-enable commercial applications under GPL license, just like one can gzip a commercial app for redistribution. I could be completely wrong about this, though :)
Another option, Apache Commons Daemon's procrun.
See http://commons.apache.org/daemon/
A program that should run as windows service must provide certain functions that the windows service manager uses to communicate with that service.
As long as there is no JVM that implements this functions directly (and I know of none) you will need some kind of wrapper.
I have successfully used srvany for a java based windows service (Basically it allows to run any program as windows service and it works fine with java)
You can use NSSM like this:
nssm install MyService "%JAVA_HOME%\bin\java.exe" -jar "path\to\the\file.jar"
I haven't tried it (yet), but Launch4j looks like it could suit your needs.
one more option winrun4j. the license is eclipse's CPL.
The most simple way I found was RunAsService.
A co-worker recommended a tool called SC, but I did not try it.
JSmooth can do it, and it is scriptable with ant.
I'm trying to figure out a way to add a self-update feature to a Java/Swing application I'm working on.
Basically I've got a bunch of jar files with extra functionality to be re-deployed to the installed users when they change. Nothing complicated, just check if a new version has been released, download them over HTTP, and then optionally offer to restart the app to the user.
I had a look at webstart, and it could work. But this particular app does some funky stuff with classloading and GC memory settings that don't look like they are supported via webstart, or will at least complicate matters. (It's a tweaked build of JMeter)
I also went down the road of adding in this plugin handler http://swing-fx.blogspot.com/2008/06/add-auto-update-and-plugins-to-your.html, but it is very alpha, and tries to do too much with the usual bugs you get with alpha stuff.
I did the exact same thing. But that was long back so there are probably better tools today.
What I found out I needed was a loader. The loader main program did not have the app jars in classpath. It first downloaded an update if required and then created a custom classloader with the app jars in class path and invoked the main method of the application main class. It is not very complicated. IIRC I needed to do this because the jars could not be overwritten in windows if they were already in classpath.
Hope this helps.
we had a swing app 6 years ago that had self-update. like you suggested,
1)it downloaded the latest jars over http,
2) copied them to a folder.
3) since the swing app is launched using a .BAT file, after user said YES, we would shut down the swing app and look for any files in the update folder. if yes, launch another .BAT file to copy the NEW JARs to the required directory.
4) then re launch the swing app.
Updates, plugins, separation of concern etc. are exactly what OSGi is about - you might want to take a look at this. It won't come free (read: with a steep initial learning curve, especially when you are currently using classloading tricks) at least there are good open source implementations (felix - see felix.apache.org, equinox - see www.eclipse.org and others)
For these implementations autoupdaters are available - if you write your modules correctly it's possible to update at runtime without restarting.
I believe you should look again at Java WebStart, or at least detail the "funky classloading" which you think is going to cause problems (as it might also cause problems with any solution proposed here).
IIRC, you can set command line parameters using Java WebStart ( http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html#resources ).
I would definitely first try out Webstart. We've had lots of success launching even the early Eclipse RCP apps using Webstart, and you can probably not get more funky classloading issues than with the OSGI framework (Eclipse Equinox).
Could you perhaps give some more detail in your question about you classloading approach?
Regarding the GC and other VM settings: these are easy to specify in your JNLP (Java Network Launching Protocol) files used by Webstart for launching apps.
The Java Web Start is good choice. The GC stuff is not important. Classloading could be problem. But when you got trusted by user you can grant AllPermisions and you will be able to do custom classloading. Maybe it will be good to reconsider funky stuff with classloading. It is really necessary? Or look at NetBeans. There should be found inspiration for auto-update.