Install4j silent upgrade without closing running application - java

With Install4j I am trying to do a silent upgrade without shutting down the app it is upgrading. I am receiving the following error "The application is running. Please close all instances and run this installer again." Is there any way around this. I am calling the installer from my code with the following code
String [] args = new String[1];
args[0] = "-q";
ApplicationLauncher.launchApplicationInProcess("6661", args, new ApplicationLauncher.Callback() {
#Override
public void exited(int i) {
logger.info("The installer exited");
}
#Override
public void prepareShutdown() {
logger.info("Calling the prepareShutowon fuction");
}
}, ApplicationLauncher.WindowMode.DIALOG, null);
This does not seem to work. The upgrade only works if I close the application which I do not want do.

With Install4j I am trying to do a silent upgrade without shutting down the app it is upgrading.
That is not possible, on Windows JAR files and executables cannot be overwritten if they are in use by a running executable.
In the updater, you need a "Shut down calling launcher" action just before the new installer is started. You have probably removed that action from the default configuration. The new installer can then restart the application automatically with an "Execute launcher" action on the "Finish" screen.

Related

NetBeans cannot connect to repository at (gitlab repository)

Yesterday I installed a new version of Netbeans (NetBeans IDE 8.2 (Build 201705191307)) and since then I can't connect to my gitlab repo (fails on trying to clone project). Credentials are fine, work on other computers and systems and I logged in over the browser(my first thought was that I tried a wrong password and banned my IP).
I use Windows 10, Java 1.8.0_31.
EDIT: Access to gitlab worked on an older version of NetBeans (not sure which one was it but above 8.0)
Updated JDK to 1.8.0_171 - still no success.
Also this was found in IDE log
INFO [org.netbeans.modules.git]: java.lang.InternalError: Should not get here
java.lang.InternalError: Should not get here
at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink0(Native Method)
at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink(WindowsNativeDispatcher.java:901)
at sun.nio.fs.WindowsFileSystemProvider.createSymbolicLink(WindowsFileSystemProvider.java:578)
at java.nio.file.Files.createSymbolicLink(Files.java:1043)
at org.eclipse.jgit.util.FileUtil.createSymLink(FileUtil.java:96)
at org.eclipse.jgit.util.FS_Win32_Java7.detectSymlinkSupport(FS_Win32_Java7.java:80)
at org.eclipse.jgit.util.FS_Win32_Java7.supportsSymlinks(FS_Win32_Java7.java:71)
at org.eclipse.jgit.internal.storage.file.FileRepository.create(FileRepository.java:306)
at org.eclipse.jgit.lib.Repository.create(Repository.java:169)
at org.netbeans.libs.git.jgit.commands.InitRepositoryCommand.run(InitRepositoryCommand.java:89)
at org.netbeans.libs.git.jgit.commands.GitCommand$1.run(GitCommand.java:80)
at org.netbeans.libs.git.jgit.commands.GitCommand$1.run(GitCommand.java:77)
at java.security.AccessController.doPrivileged(Native Method)
at org.netbeans.libs.git.jgit.commands.GitCommand.execute(GitCommand.java:77)
at org.netbeans.libs.git.GitClient.init(GitClient.java:871)
at org.netbeans.modules.git.client.GitClient$33.call(GitClient.java:574)
at org.netbeans.modules.git.client.GitClient$33.call(GitClient.java:570)
at org.netbeans.modules.git.client.GitClient$CommandInvoker$1$1.call(GitClient.java:956)
at org.netbeans.modules.git.client.GitClient$CommandInvoker$1.call(GitClient.java:979)
at org.netbeans.modules.git.FilesystemInterceptor.runWithoutExternalEvents(FilesystemInterceptor.java:496)
at org.netbeans.modules.git.Git.runWithoutExternalEvents(Git.java:282)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethodIntern(GitClient.java:989)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethod(GitClient.java:916)
Caused: org.netbeans.libs.git.GitException
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethod(GitClient.java:932)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethod(GitClient.java:898)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.access$400(GitClient.java:892)
at org.netbeans.modules.git.client.GitClient.init(GitClient.java:570)
[catch] at org.netbeans.modules.git.ui.clone.RepositoryStep$RepositoryStepProgressSupport.perform(RepositoryStep.java:323)
at org.netbeans.modules.git.client.GitProgressSupport.performIntern(GitProgressSupport.java:115)
at org.netbeans.modules.git.client.GitProgressSupport.run(GitProgressSupport.java:108)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
The stack trace shows that the code failed when trying to create a symbolic link by calling Files.createSymbolicLink(). To do that on Windows 10 you must run with Administrator rights, or you need to have the right to create a symbolic link, so the true solution to your problem is to set appropriate User Account Control (UAC). This is the case even if you created the file or directory to which you want to add a symbolic link.
If you open a Command Prompt window, create a directory and then try to add a symbolic link it will fail with the error "You do not have sufficient privilege to perform this operation", but if you do the same thing when selecting Run as Administrator before opening a Command Prompt window it works fine:
The same principles apply when creating a symbolic link in a Java application on Windows 10, and again the proper solution is to set UAC appropriately. However, there is an easy workaround solution: just as you can open a Command Prompt window as an administrator, you can also run NetBeans as an administrator:
Once you do that the java.lang.InternalError should be gone.
You can run the trivial Java application below to confirm that admin rights are needed when creating a symbolic link under Windows 10. The application fails with a FileSystemException ("A required privilege is not held by the client.") when calling Files.createSymbolicLink() from NetBeans if it is started normally, but works fine when NetBeans is Run as administrator.
public class SymLink {
public static void main(String... args) throws IOException {
String originName = "c:\\ThisIsJunk";
String targetName = originName + "SymLnk";
Path origin = Files.createDirectories(Paths.get(originName));
Path target = Paths.get(targetName);
try {
Files.delete(target);
} catch (NoSuchFileException e) {
}
try {
Path symLink = Files.createSymbolicLink(target, origin);
System.out.println("Symbolic link created: " + symLink.toString());
} catch (AccessDeniedException e) {
e.printStackTrace();
}
}
}
After having the same issue mentioned above while running in Administrator Mode, I noticed I had Netbeans running in Windows 8 Compatibility mode. Unchecking compatibility mode, I was then able to connect to the Github repository.

JxBrowser with Java Swing (IntelliJ plugin) - "Received signal 10 BUS_ADRERR"

I'm writing an IntelliJ plugin, and attempting to integrate JxBrowser into the plugin's tool window via Java Swing.
I'm using the toolWindow extension to keep the tool window integration simple.
plugin.xml
<extensions defaultExtensionNs="com.intellij">
<toolWindow id="pluginid" anchor="right" factoryClass="com.solutionloft.codeclippy.MainWindowFactory" />
</extensions>
And so my main factory class looks like this:
public class MainWindowFactory implements ToolWindowFactory {
#Override
public void createToolWindowContent(#NotNull Project project, #NotNull ToolWindow toolWindow) {
Browser browser = new Browser();
BrowserView view = new BrowserView(browser);
Content content = toolWindow.getContentManager().getFactory().createContent(view, "", false);
toolWindow.getContentManager().addContent(content);
browser.loadHTML("<html><body><h1>Hello World!</h1></body></html>");
}
}
This appears to work when I run the plugin locally initially (the tool window comes up, and I can see Hello World), but if I terminate the process and then try to run it again, I run into this error:
Received signal 10 BUS_ADRERR 000103bc3000
[0x00017cd9540c]
[0x00017cd95301]
[0x7fff572eef5a]
[0x7fbe7e9f5000]
[end of stack trace]
Process finished with exit code 138 (interrupted by signal 10: SIGBUS)
Am I missing some kind of cleanup step? I'm not sure what could still be running - the only workaround I've found at this point is to do a full computer restart, so I guess some process must be still running that's causing it to conflict. What's the proper way to clean up? Does it have anything to do with browser.dispose()? I haven't had much luck finding documentation on when .dispose() would be appropriate / if it's needed.
I'm using:
* macOS High Sierra
* Java 1.8.0_151 as my JDK
* PyCharm Ultimate as my JRE
Thanks!
Update: Noticed if I kill this process /System/Library/Frameworks/LocalAuthentication.framework/Support/coreauthd, the problem goes away for the next few runs. But sometimes this process doesn't exist and killing a still-running java process is the fix... odd.
According to TeamDev support, the solution is to set the system property jxbrowser.ipc.external=true. Calling System.setProperty("jxbrowser.ipc.external", "true") before you create your browser instance should do the trick. The catch is that the JxBrowser will run in lightweight mode.
You may also ensure that you're properly disposing all browser instances via browser.dispose() and the Chromium engine via BrowserCore.shutdown().
According to the article, all browser instances should disposed when you don't need them. Please try disposing all browser instances before closing your application.

how to halt installanywhere installer process if intended target application already running

We deploy a Java application using InstallAnywhere 2012.
The deployed application has a version notification mechanism, which pops up a website, and encourages the user to download and launch "new version" while the "old version" may still be running. There is a "please exit" dialog during this process but the users usually don't exit, and the act of installing "new version" typically only overwrites files which were not locked, which yields a non-working installation until the user does a clean re-install.
I'd like to modify the actual installer to bail if "old version" is currently running, asking the user to quit it first.
IA offers a way to "execute custom code" which can be pointed to a jar file. So I created a standalone runnable jar program that exits with code 0 if all is clear, or code 1 if "old version" is detected as running, relying on tasklist.exe's return and some string parsing. However, I can't seem to find a way to alter the course of the installer based on my program's output.
Has anyone else tried doing this in IA platform, and if successful, how did you go about it?
Configure a custom code action . Keep the following as reference.
public class PreviousVersionCheck extends CustomActionBase{
#Override
public void install(InstallerProxy proxy) throws InstallException {
boolean oldVersionRunning = isOldVersionRunning();//Logic to check if old version running.
proxy.setVariable("$OLD_VERSION_RUNNING$",oldVersionRunning)
}
}
After the custom code action , add a "Show Message Dialoge" .
Add the rule for the action as
$OLD_VERSION_RUNNING$ equals true
In the action properties, you have cancel and exit option,on click of dialouge Button..
Hope this helps..

How to detect JavaFX 2.2 runtime availability

I am using the javaFX 2.2 with jdk1.6 in a swing environment. I am trying to display a browser on the JPanel and i am successfully able to do this.
THe only problem i see is when i run my application on any other machine which doesn't have the javaFX2.2 runtime env it gets stuck and doesn't display any error message.
How can I make sure that if the javafx runtime env. is available on the machine or not before doing
new JFXPanel()
because code stuck at the above line.
boolean isJavaFxAvailable;
try {
Class jfxPanel = classLoader.loadClass("javafx.embed.swing.JFXPanel");
isJavaFxAvailable = true;
} catch (ClassNotFoundException e) {
isJavaFxAvailable = false;
}
There needs to be a JavaFX runtime at every maschine which runs a JavaFX application. I beleave this runime may be delivered by a webstart, but it must accessable.
Take a look here:
How to get the version number of JavaFX?

Debugging JNLP started application

I created a Java desktop-application (using Swing) and am now trying to make it work by starting it from the net using JNLP. The application works fine when I start it from the terminal, but as soon as I launch it from JNLP, it does not close. I have to manually kill the process every time.
I read that there might be a problem if my JFrame uses DISPOSE_ON_CLOSE as the default close-operation, but it doesn't. It uses DO_NOTHING_ON_CLOSE (implicitly). Also, I'm explicitly calling System.exit(0) after releasing all my objects:
f = new JFrame("Pacman");
f.addWindowListener(new WindowAdapter() {
#Override
public void windowClosing(WindowEvent e) {
// Terminate the Game-loop:
GameLoop.INSTANCE.stopLoop();
// Close the application:
System.exit(0);
}
});
I guess that there might be an exception thrown when I close the application, but I can't find a way to get the console-output (e.g. the Stack-Trace) of a running application started with JNLP. Here's what I tried:
Start javaws with the debugging parameters and connect with jconsole (works but I can't find any exception- or console-ouput).
Start javaws with the debugging parameters and attach IntelliJ debugger to it (also works but does not give me any output)
So, how can I start the application with JNLP and get the output (written to the default out- and error-streams), as if I would do with a normal desktop application?
Solution #1 - Enable Java Console, and look for exceptions.
You can do it via Java Control Panel. Switch to Advanced tab, and in the Java Console make sure Show console is selected.
Then, run your application and monitor the console for exceptions. Fix the exception.
Solution #2 - Debug your running application (properly).
Start the Web Start app like this (for Java 1.6 and newer):
javaws -verbose -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=8123 http://myserver.com/path/to/myapp.jnlp
If using earlier java versions (1.4.2, 1.5) set the environment variable, like this:
set JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=8123"
and run the app via:
javaws http://myserver.com/path/to/myapp.jnlp
When the app runs:
Attach a debugger (Eclipse will do - use Run => Debug Configurations => Remote Java Application, and in Connection Properties panel enter the port passed in the parameters to javaws (in this case: 8123).
Set a breakpoint inside your windowClosing method.
Try to close your application - Eclipse should break the execution on your breakpoint
Step into the GameLoop.INSTANCE.stopLoop() method to see where/when it hangs.
Don't expect to see a solutions in the console, just step through the code with a debugger - if the application hangs, it will show you where.
There are times when even the console doesn't show anything, for example when there is a problem with the TLS/SSL handshake (i.e. a close_notify or handshake_failure). In these cases you need to do the following:
Enable the Java logs and tracing in the Java Control Panel > Advanced.
Enable parameters for debugging Java & launching the JNLP, there are two ways you can do it:
2.a. Download the JNLP file and execute it from command line (the SET command is not required in this particular case).
set JAVA_TOOL_OPTIONS=-Djavax.net.debug=all
javaws -wait jnlp.jnlp
2.b. Add arguments (i.e. -Djavax.net.debug=all) for the JVM in the Java Control Panel > Java > View (this is not required in this particular), and launch the JNLP file from browser:
The logs and traces are located in the log directory from the Java Deployment Home from where I paste these locations:
a. Windows XP: %HOME%\Application Data\Sun\Java\Deployment
b. Windows 7/Vista: %APPDATA%\..\LocalLow\Sun\Java\Deployment
c. Linux/Solaris: %HOME%/.java/deployment
This answer is an alternative to npe answer to enable the remote debug (Windows).
Go to Control Panel;
Click on Java, to open Java Control Panel;
Inside of Java Control Panel, go to Java tab, and click "View";
This will open a window with installed java versions. On runtime parameters put "-Xdebug -Xrunjdwp:transport=dt_socket,address=8123,server=y,suspend=n" (if you want to debug when application is starting, change to "suspend" to "y", that will make the application stop until an editor connect remotely);
Afer that, configure you editor to debug remotely to the configured port (localhost:8123 in this case).

Categories