Comments (4)
It appears that the -splash VM argument is processed and filtered by the java executable, and not forwarded to / ignored by libjvm. WinRun4J for example implements its own solution, which isn't cross-platform.
from packr.
Thanks for rply.. that means it is not possible to use splashscreen with packr.
from packr.
No. Not per VM option. And I believe it would be a major pain to add custom support, like WinRun4J does, which works well on all platforms.
I don't know your requirements. If you really need a splash screen of some kind, it may be feasible to do one in Java instead. Loading and starting the JVM doesn't need much time on desktop systems.
from packr.
Once again thanks for your suggestion, I implemented splash screen in java itself. Actually my application takes a while in starting up, thats why splash screen was badly needed. This is what I did..
package org.shikhar.simphy;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import javax.swing.JFrame;
/**
* Derived from
* https://www.randelshofer.ch/oop/javasplash/javasplash.html#secondsplash
*
* @author Mahesh kurmi
*
*/
public class SplashWindow extends JFrame {
private static SplashWindow instance;
private Image image;
private boolean paintCalled = false;
private String msg = "";
/**
* The main method does three things:
* 1. Open the splash window
* 2. Invoke the main method of class Sandbox (Main app class)
* 3. Close the splash window when the main method of Sandbox returns
* @param args
*/
public static void main(String[] args) {
SplashWindow.splash();
SplashWindow.invokeMain("org.shikhar.simphy.Sandbox", args);
SplashWindow.disposeSplash();
}
public static void splash() {
/*
* In the first splash() method we use the AWT Toolkit class to create
* the image. We use this method instead of the new Image IO API,
* because it does not immediately load the image using the current
* thread.
*/
splash(Toolkit.getDefaultToolkit().createImage(
SplashWindow.class
.getResource("/org/shikhar/simphy/images/splash.png")));
// ImageUtilities.getIconFromClassPathSuppressExceptions("/org/shikhar/simphy/images/splash.png").getImage());
}
private SplashWindow(Image image) {
super();
this.image = image;
MediaTracker mt = new MediaTracker(this);
mt.addImage(image, 0);
try {
mt.waitForID(0);
} catch (InterruptedException ie) {
}
}
/**
* Here we invoke the main() method of our application using, er, clumsy Reflection code.
* @param className
* @param args
*/
private static void invokeMain(String className, String[] args) {
try {
Class.forName(className)
.getMethod("main", new Class[] { String[].class })
.invoke(null, new Object[] { args });
} catch (Exception e) {
InternalError error =
new InternalError("Failed to invoke main method");
error.initCause(e);
throw error;
}
}
private static void splash(Image image) {
/*
* an instance of the SplashWindow is created then, the instance is shown. And then,
* we wait in a synchronized block until the paint method of the
* instance has been called.
*/
if (instance == null && image != null) {
instance = new SplashWindow(image);
instance.setSize(816, 251);
instance.setUndecorated(true);
instance.setLocationRelativeTo(null);
instance.setVisible(true);
if (!EventQueue.isDispatchThread()
&& Runtime.getRuntime().availableProcessors() == 1) {
synchronized (instance) {
while (!instance.paintCalled) {
try {
instance.wait();
} catch (InterruptedException e) {
}
}
}
}
}
}
@Override
public void update(Graphics g) {
paint(g);
}
@Override
public void paint(Graphics g) {
if (image == null) {
System.out.println("image is null");
return;
}
if (g == null) {
System.out.println("g is null");
return;
}
Graphics2D g2D = (Graphics2D) g;
g2D.drawImage(image, 0, 0, this);
g2D.setColor(new Color(239, 127, 34));
g2D.fillRect(543, 34, 800, 30);
g2D.setColor(new Color(255, 255, 255));
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2D.drawString(msg + "...", 543, 52);
if (!paintCalled) {
paintCalled = true;
synchronized (this) {
notifyAll();
}
}
}
/**Called from Sandbox class to set progress */
public static void setProgress(String msg, int percentage) {
if (instance == null)
return;
instance.msg = msg;
instance.repaint();
}
/**
* free resources if any
*/
public static void disposeSplash() {
if (instance == null)
return;
instance.setVisible(false);
instance.image.flush();
instance.image = null;
instance.dispose();
instance = null;
}
}
For now it does the job, but I am not much comfortable with JVM loading mechanism so there may be few problems with the implementation. Kindly reply if there is any improvement needed.
from packr.
Related Issues (20)
- XstartOnFirstThread hangs forever on OSX HOT 1
- LWJGL3 crashes on OSX HOT 4
- Packr cannot recognise `jrePath` Temurin JRE and JDK zips for Windows HOT 8
- Load configuration file relative to executable location, not working directory HOT 1
- Can you create Linux binary that makes use of installed Java on Linux instead of packaging one with packr?
- How to make generated app to use current working dir as its working dir instead of app's dir?
- FEATURE REQUEST HOT 1
- Consulting: Complicated packaging methods
- Packing with Oracle JDK causes error HOT 2
- Mac keeps throwing permission denied HOT 1
- Error 503 from https://artifactory.nimblygames.com while building HOT 1
- Version 4.0.0 missing from artifactory HOT 2
- Error when execute .exe file
- classpath is empty when retrieving it.
- Frame blurry when starting with bundled launcher
- Can you add an option to remove the previous out directory if it exists?
- Generated .exe does nothing HOT 8
- packr repo seems not to work HOT 1
- 关于windows打包的问题
- 关于linux/macos打包的问题 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from packr.