I recently upgraded my application from Java 8 up to Java 12. I used to distribute as a runnable jar file, but am now distributing a runnable image. In the past, I defined a splash screen in the manifest which would display while the app loads (and well before a single line of my code ran). Is there any equivalent functionality I can use now that I have switched from running from a jar file to running from an image?
Check the documentation of java.awt.SplashScreen:
If the Java implementation provides the command-line interface and you run your application by using the command line or a shortcut, use the Java application launcher option to show a splash screen. The Oracle reference implementation allows you to specify the splash screen image location with the -splash: option.
For example:
java -splash:filename.gif Test
or of the java command:
-splash:imagepath
Shows the splash screen with the image specified by imagepath. HiDPI scaled images are automatically supported and used if available. The unscaled image file name, such as image.ext, should always be passed as the argument to the -splash option. The most appropriate scaled image provided is picked up automatically.
For example, to show the splash.gif file from the images directory when starting your application, use the following option:
-splash:images/splash.gif
Related
On a Mac, there is a button on the screen menu bar that is the name of an application. For example, for terminal, there is a button at the top of the screen labeled Terminal. When you click it, there is a options that says About Terminal. When this is clicked, it shows information about the application. Here is a picture:
How can I add this to my application in Java? When I do this now, this is what shows up:
As you can see, it shows the Java version etc. Is there a way to change this into a more professional format?
If your Window extends JFrame, just use the setIconImage or setIconImages method to set your icon.
From the corresponding JavaDoc:
Sets the image to be displayed as the icon for this window.
The other information is read from the executable metadata. If you run your app using Java directly, you can't change it. For my applications, I generate an executable file using Install4J, where the installer adds the metadata to the generated executable.
Thanks, I've solved the problem. It was a simple mistake, when I packaged it together using a packager it worked fine. Thanks for all your help!
I read on another forum that to launch draw9pad from your console, you have to do java -jar draw9patch.jar from the command prompt once youre in sdk. I did that but i still cannot launch the file. Is this tool absolutely necessary for your pictures to scale on different screens? I know that eclipse has these drawable folders that scale your pictures to different dpis or is that not what they do?
Console output: http://imgur.com/YdGLHXr
File skd/tools :http://imgur.com/vOU647L
To answer the first question for a Mac OS or Linux user, simply type sh draw9patch to launch the editor. CommonsWare already answered the second question.
I read on another forum that to launch draw9pad from your console, you have to do java -jar draw9patch.jar from the command prompt once youre in sdk
Please use the draw9patch batch file or shell script found in the tools/ directory of your SDK installation.
I did that but i still cannot launch the file
First, that is because you did not type it in correctly, as you did not include the .jar extension.
Second, that JAR file is not in that directory. You can tell that by looking at the directory contents.
Instructions for running draw9patch can be found in the Android documentation.
Is this tool absolutely necessary for your pictures to scale on different screens?
Quoting the documentation:
A NinePatchDrawable graphic is a stretchable bitmap image, which Android will automatically resize to accommodate the contents of the View in which you have placed it as the background.
Scaling for different screens is not really the role of a nine-patch PNG file. Scaling for different content is. A nine-patch is used as the background for widgets like Button, EditText, and the like.
I'm trying to export my current project as a jar for testing purpose, but when ever I export it as an external jar, it works fine on my computer, but on my friends computer it just displays a grey screen.
My export settings are as followed:
Library Handling - Extract required libraries into generated JAR.
Any ideas on why it's not working?
What is meant to be displayed: http://i.stack.imgur.com/ArObt.png
These pixels are also moving across the screen horizontally in a constant loop, but for obvious reasons, you cannot see this(This is a picture xD).
This is from my computer by the way, but on another computer, its just a grey screen.
IDE: Eclipse
Both of us are using the same operating system.(Windows 7)
The program runs fine when launched in both run, and debug mode, no exceptions are thrown.
Jar runs fine on my computer.
Main Class: http://pastebin.com/fFcPsqnm
I'd like to drop a file onto my jar and have the filename passed on to my main method as argument.
I'm on OSX.
How can I do that?
If the app. is deployed using Java Web Start, a file association can be declared. Double click any file of that type and the path of the file is supplied to the main(String[]).
BTW - here is a demo. of the JNLP file API. Note well the 2nd bug report, which would mean a minimum version of 1.6.0_10+ in order not to delete a file dropped on the application's icon.
To do this on OSX you might have to create an application bundle from your .jar. This process is documented pretty well at the Apple Developer Center (scroll down to "Mac OS X Application Bundles"). You can build a Java app which blends really well into the OSX desktop if you follow what they present there, and it's pretty easy.
First I have read all questions about this subject, so this is not a repeated question.
What I want to ask about, how an application written in Java (such as eclipse) uses an icon instead of the default jar icons.
I don't care about compatibility, I always can make 2 different versions of my program to Windows and Linux.
How to make it in Linux and Windows.
Thanks very much.
In the case of programs like eclipse, which are written in java and have a specific icon in Windows (or Linux or Mac for that matter), they actually have an OS specific executable file, e.g. eclipse.exe for windows, that initialises the java program.
It is this executable that contains the application icon, not the Java program. If you want to do the same, you'll need to create the executable 'front door', as it were, and give it an icon.
If it's just for your own personal aesthetics, just create a short cut to the jar file and change the icon of the shortcut.
To set an image for MAC, you can use com.apple.eawt.Application. try this:
Image img = new ImageIcon("abc.png").getImage(); // your desired image
Application app = Application.getApplication();
app.setDockIconImage(img);
However, this will not build on Windows or Linux by default. If you'd like it to, (Maven) add the following dependency to your POM:
<dependency>
<groupId>com.yuvimasory</groupId>
<artifactId>orange-extensions</artifactId>
<version>1.3.0</version>
</dependency>
Or, if you don't use Maven, you can download the JAR from http://central.maven.org/maven2/com/yuvimasory/orange-extensions/1.3.0/orange-extensions-1.3.0.jar
If the application is launched using Java Web Start, an application icon can be specified for use in desktop shortcuts and menu items.
Note that this icon is not attached directly to the Jar, but since the end user never sees or has to deal with a Jar, that should not be a problem.
I use NetBeans, so if you aren't using that, I don't quite know. But, when you select the window, there is an option in the properties window for an icon file. When you build the .jar, that icon should be built in with the program.
If you're talking about the actual application icon in, say, Windows, you can't change it (programmatically). That's determined by the OS. Although you can change it in your OS in Folder Options.
You can, however, set the window (read: JFrame) icon image using setIconImage().