I'm using the javafx-maven-plugin and IntelliJ IDEA on Windows 7.
I'm trying to get a splash screen to show while my JavaFX application boots up, like this:
I tried using the SplashScreen-Image manifest entry—and that works, but only if you click on the .jar—I'm deploying the application as a Native Bundle and so the user clicks an .exe (or a shortcut to an .exe) not the actual .jar.
When you click the .exe no splash screen is shown.
This SSCCE I made will help you help me.
If I'm deploying my app using the javafx-maven-plugin, (which, if I'm not mistaken, uses the JavaFX Packager Tool, which uses Inno Setup), how can I get a splash screen to show after the user clicks the .exe?
More Findings:
Looking at the installation directory, I find a .dll called runtime\bin\splashscreen.dll. Does that mean it can be done?
The native launcher does not respect that spash-screen, it is only when being invoked by the java-executable. As the native launcher is loading the JVM internally, this won't work.
I haven't found a proper way to get this working, not even with some preloaders. Maybe you can find this helpful: https://gist.github.com/FibreFoX/294012b16fa10519674b (please ignore the deltaspike-related stuff)
Copied code:
#Override
public void start(Stage primaryStage) throws Exception {
// due to the nature of preloader being ignored within native-package, show it here
SplashScreen splashScreen = new SplashScreen();
splashScreen.show(new Stage(StageStyle.TRANSPARENT));
// needed for callback
final SomeJavaFXClassWithCDI launcherThread = this;
// for splashscreen to be shown, its needed to delay everything else as parallel task/thread (it would block otherwise)
Task cdiTask = new Task<Void>() {
#Override
protected Void call() throws Exception {
// boot CDI after javaFX-splash (this will "halt" the application due to the work done by CDI-provider
bootCDI(launcherThread);
// push javaFX-work to javaFX-thread
Platform.runLater(() -> {
primaryStage.setTitle("Some Title");
// TODO prepare your stage here !
// smooth fade-out of slashscreen
splashScreen.fadeOut((ActionEvent event) -> {
primaryStage.show();
splashScreen.hide();
});
});
return null;
}
};
// run task
new Thread(cdiTask).start();
}
In short: I'm creating my splashscreen myself.
Disclaimer: I'm the maintainer of the javafx-maven-plugin
Related
Context
I am using VS 2017.3 to develop Xamarin.Forms application. I am trying to diagnose where and why an Exception occur on my code.
I can successfully deploy run and debug my application using the SDK Android Emulator (HAX x86).
However in case an Exception occur I can not see any information about the Exception, see attached picture, settings.
Question
Is this normal in Android debugging, or missing I something?
...and my build settings:
I wanted to expand on #Uraitz's answer because it helped me figure out the problem.
First, as he explains, you will want to add an event handler in your activity, as shown in the following code:
protected override void OnCreate(Bundle savedInstanceState)
{
...
//subscribe to unhandled event
AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
...
}
private void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
}
In my case I put a breakpoint inside CurrentDomainUnhandledException so I could inspect the exception.
However, even with that breakpoint in there, I ran my code and still got a confusing no-callstack error.
At this point I thought the solution wasn't working. In fact it is, but I had to click the Play (continue) button multiple times before my app would hit the breakpoint:
After clicking that button two times, I finally hit the breakpoint:
If you want to get the callstack in the debugger, you will have to dive in a few levels before it is available, but you can do so by looking at the event args parameter.
The moral of the story is - if you have added the event handler but you still aren't hitting the breakpoint (or seeing output) - keep clicking the Continue button!
Just continue, then look through the Output, it will show you the stack trace of the exception. It is a good idea to learn how to read through the log files to find information about exceptions.
You can subscribe on each platform main constructor to UnhandledException event this will give you more information about exception before break debug.
for example in Android:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
//subscribe to unhandled event
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
}
}
If you need each platform explanation ask for them :)
Deleting the bin and obj folders solved it in my case.
I got similar issue, after investigating, I just have to disable the Xamarin Inspector.
Ill just throw this in the mix.
I was getting a "No compatible code running" error when attempting to break on otherwise 'working' code.
After struggling with this I decided to go back to an older version of visual studio where it didn't happening.
This gave me the idea to reset my Exception settings, and then the issue went away.
Seemingly there are a number of handled exceptions that any given library might be throwing, and if you choose to break on a particular condition you may well see this.
Firefox browser only launches on Dock on my Mac but active screen shown is still Eclipse.
How can the focus be shifted to Browser?
public class FirefoxFirst {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver","/Users/varunnadimpalli/Downloads/geckodriver");
WebDriver driver = new FirefoxDriver();
driver.get("https://google.com");
selenium :3.3.1
Mac:`10.12.1
Strange why it wouldn't swap focus to firefox, if it is not in focus but still open try
((JavascriptExecutor) webDriver).executeScript("window.focus();");
If it is minimized you can try going through the windows handles
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
See if that is able to bring the firefox window up.
Not sure whether this works. Try maximizing the browser,
driver.manage().window().maximize();
Also, don't forget to add implicit wait after initiating the browser.
Note - I don't have enough points to comment this. else i have commented instead of writing this as answer.
How can I change the icon image of my JavaFX application?
And is possible to run my application without java installed on computer?
You can set the image of your primary stage
#Override
public void start(final Stage stage)
{
stage.getIcons().add(new Image("icon.png"));
}
And yes you can run your application on a system without the run-time, for this you must have the run-time embedded in your application
stage.getIcons().add(new Image("yourImage.extension"));
In regards to your second question, I know this exists, but I never used it.
That would be a self contained app. Check this site:
http://docs.oracle.com/javafx/2/deployment/self-contained-packaging.htm
I am new to Processing development environment, I did my homework and all I found is to import processing libraries into Java IDE (eclipse) and use debugging, I am wondering if there is a PDE plugin that can help with intellisense and debugging as for small sketches PDE is very convenient.
Debugging
Since the launch of Processing 3, debugging is now a native feature of the Processing IDE.
In the screenshot below, you'll see a new Debug menu. I set breakpoints on the setup() and draw() methods as indicated by the <> marks in the line numbers. To the right is a popout window listing variable and object values, etc.
Intellisense
From the Preferences menu, check the box Code completion with Ctrl-space.
Then, you can start typing a function like ellipse and press CTRL+Space to pop intellisense. Moreover, with that turned on, accessing properties or methods of an object by typing a . after should automatically pop intellisense.
Using Another IDE
Finally, you could take advantage of a more powerful IDE by importing the processing core.jar into any Java project. The core.jar file is located relative to your Processing installation, such as:
OSX: /Applications/Processing 3.0.1.app/Contents/Java/core/library/core.jar
Windows: \Program Files\processing-3.0.2\core\library\core.jar
In Processing 1 and 2, this must be run as Applet. In Processing 3, run as Java Application. Here's an example to demonstrate:
import processing.core.*;
public class Main extends PApplet {
// In Eclipse, run this project as Java Application (not Applet)
public static void main(String[] args) {
String[] a = {"MAIN"};
PApplet.runSketch(a, new Main());
}
public void settings() { // <-- that's different
size(500, 500); // necessary here to prevent runtime IllegalStateException
}
public void setup() {
// other one and done operations
}
public void draw() {
ellipse(mouseX, mouseY, 40, 40);
}
}
Check out this post if you want to write Processing code in Eclipse across multiple classes.
https://processing.org/tutorials/eclipse/
Unfortunately you can't get those features within the compact Processing development environment.
You can get autocompletion/intellisense with a decent Java IDE like IntelliJ or eclipse.
Personally I'm pretty happy with how the Proclipsing eclipse plugin integrates with Processing (easy project export, library management, etc.)
Check out this video guide on setting up:
If you use the latest Processing 2.0b7 version, and enable the 'EXPERIMENTAL' mode (top right corner), you have access to a small set of tools (breakpoints, step by step) and a realtime debugging console. It can't compare to other platforms such as VS or Eclipse, but it is a good start and gets some of the work done.
I've never tried, but for Processing 2.x there is this tool for debugging. It has been discussed in this topic in procesing forum.
I've got a tiny Portal I´m writing, and this portal is supposed to launch installers on button click. I´m developing on VS2010 on a WinXP SP3 station, and on this machine, even fter compilation and publishing, everything works as expected. However, when i run the compiled application in Windows 7, it crashes...The application work, it just crashes when i click a button for program installation.
The programming looks like this:
private void button_access_Click(object sender, RoutedEventArgs e)
{
Process executable = new Process();
string executablePath = "D:\\Visual Studio 2010\\SAFE_Portal1\\SAFE_Portal1\\Extra Programs\\AccessRT2003.exe";
executable.StartInfo.FileName = executablePath;
executable.Start();
}
It specifically crashes on thr button_access_Click procedure...
Any ideas as to why this could be? I`ve tried looking around here in Stackoverflow, and in other forums, but to no avail...
Any help or direction is ganz welcome!
Try this:
try
{
Process executable = new Process();
string executablePath = "D:\\Visual Studio 2010\\SAFE_Portal1\\SAFE_Portal1\\Extra Programs\\AccessRT2003.exe";
executable.StartInfo.FileName = executablePath;
executable.Start();
}
catch (Exception msg)
{
MessageBox.Show(msg.Message);
}
What message are you getting?
Are you sure you want to use fixed paths in your application? If so you should at least check if the file you try to start exists beforehand. Otherwise an exception will be thrown which could be the problem here.
if (File.Exists(executablePath))
{
...
}