Creating Menu Entries for User Applications, Linux - java

Hi I have created an rpm file. My application is completely java application. When I install my rpm I have to double click on Install.sh (its a shell script file which start java application) my program starts. Now I want when i will install my rpm file an icon will be seen in desktop. and by clicking on that icon my application must start.
Whether I have to set anything in my .spec file
What I have to do to achieve this.
I am using Fedora10
Thanks
Sunil Kumar Sahoo

Usually, RPM files install a foo.desktop file which will add a menu entry in the Applications menu.

You can take a rpm that is known to do this, extract it and read it's spec file
This will provide the required hints regrading the described behavior
Mangling
1.
Unpack rpm
rpm2cpio httpd-2.0.52-32.ent.i386.rpm | cpio -idmv --no-absolute-filenames
2.
View install scripts
rpm -qp --scripts --triggers httpd-2.0.52-32.ent.i386.rpm
Also check http://susefaq.sourceforge.net/articles/rpm.html

Related

How do I install and set up Java speech (jsapi) for my iMac running the latest OS Sierra?

I am relatively new to Apple OS and thus am not able to figure out as to how do I download, install then set up Java speech jar files and set up the classpath.
I tried everything possible from
Downloading FreeTTS,jsapi and trying to add the jsapi.jar to /library/extensions folder
Trying to use chmod command
Trying to open the jar file (which returned an error and asked me to check console)
Tutorials asking me to drop jar into the "lib" folder (I can't really figure out what and where is the "lib" folder in mac)
Basically I want to use all the capabilities of javax.speech in my Java programs.
JSAPI is pretty much abandoned, you won't be able to get lot from it. If you want text-to-speech use OpenMary directly without JSAPI, it provides a good selection of modern voices.
Download FreeTTS. Extract. Open the extracted /lib folder. chmod +x ./jsapi.sh and afterwards sh ./jsapi. Read the BCEL and accept.
Accept (y/n)?:
y
sed: --print-text-domain-dir: No such file or directory
x - creating lock directory
x - extracting jsapi.jar (binary)
As you can see there is the jsapi.jarbeing extracted into the lib folder (which was not there before). Now you can add the lib folder (it says it will be enough to point to the lib/freetts.jar) to your class path of any application that is using FreeTTS.
You could add it into some directory in your userspace folder and add to your ~/.bash_profile the line export JS_API_HOME=~/the/path/lib where ~/the/path would be where you stored the extracted archive. Then, you have to add the environment variable $JS_API_HOME to every build/classpath where you want to use the library.
For example, java -cp $JS_API_HOME -jar moep.jar

Java application will run from CMD and Eclipse but not double click

I've done a search and I can see that a lot of people have had the same problem as me, but none of the solutions have worked for me.
Basically I have a Java Project in Eclipse that is from my old Windows Installation. I've cleaned and rebuilt it because at first it wouldn't compile, but now I have it exported as a Runnable Jar. However, the only way I can get the application to appear is to do java -jar foo.jar in command prompt, or run it in Eclipse. If I double click the JAR in Windows Explorer nothing happens even though I know that Java is associated correctly because other Runnable Jars work.
The project only has the x86 JRE listed in it's Build Path Libraries and all the files listed appear to exist. I'm running Windows 7 HP.
Update: I'm sorry, but I just discovered that no other Runnable Jars are working either. If they are wrapped with launch4j they work though...
Edit: The Runnable Jars that I export from Eclipse do work fine on other systems and load on double click
Some registry values or file associations are probably messed up. Wiping off all of your existing JRE's and JDK's and re-installing them should fix your issue.
Alternatively you may be able to fix it by manually editing the registry value here:
HKLM > SOFTWARE > Classes > jarfile > shell > open > command
My value is
Type: REG_SZ
Data: "C:\Program Files\Java\jre8\bin\javaw.exe" -jar "%1" %*
You'd of course want that path to point to your javaw.exe, and make sure you have the additional arguments.
I was also facing the same problem while i was working with Spring tool suite.
You may use the following steps:-
Right click on project -> export -> Runnable jar file -> (Here,In library handling,there are three options,you have to choose middle one i.e package required library into generated jar.It will package external dependency also).
-In my case, my runnable jar was only executing on my environment i.e on which i have created that JAR. Initially i have selected the first option to create JAR i.e extract required libraries into required JAR.but that was not proper.
It may help you.Let me correct if i am getting wrong.
Since you are able to run the JAR running the command line, I believe your issue is related to which version of Java is set to run the file when it is double-clicked.
To find out which version is successfully running the file from the command line and set it to open JAR files by default:
Open a new command prompt window.
Run echo %path%. Among the path values, you should be able to find one pointing to the bin folder of one of the installed versions of Java. Copy this path somewhere.
Navigate to the JAR file you would like to run. Right click the JAR -> Open with -> Choose default program... -> Browse...
Browse to the path you copied in step 2. (the easiest way is to paste it into the address bar)
Double click javaw.exe.
Click OK.
You should now be able to run the JAR file. Please let me know if your problem persists.
I have made a jar with and keep it on desktop.Then,I double clicked on the jar and it working fine for me.
How I and what I have monintored: In my main class, perform some operation and at the end I add on Thread.sleep(25000); to hold the program for few moments. After every double click on the exported jar I found one new javaw.exe process added in the system process tree. I have noticed it on Task manager. and after 25000ms respective javaw.exe process ended. As my application does not cointain any GUI that's why I have not seen any GUI changes for the respective process. I'm Confident that if my application have some GUI, I will surely get the respective GUI window on every run.
Common mistakes : when we export a project from Eclipse as Runnable JAR file, it is exported with selected Eclipse launch configuration and Eclipse specific launch wrappers. Now if the configuration does not match when you are trying to run it via double-click you will not be able to see the error, If you run it from CMD then surely you will get the error log.
To create standard executable JAR file : To create a standard executable JAR file, you can export as JAR file and specify the main class in last screen of the wizard.
That's working for me fine. I used the same jar from different system and keeping it different location.

how to add/remove any application's EXE programmatically

If we would like to start some applications automatically we use to put them in start-up folder in windows environment, how to add/remove any application's EXE programmatically. i am using java for my application.
Detail With Background: Working on a desktop based application, and using Advanced Installer to create the installer for app, it is working fine, issue is we have an option to add/remove the short cut of app's EXE in order to start app on system start-up, The Advanced Installer gives option to add the EXE file into start-up but how to add/remove it using java, as its a java based application
I just need to get some idea about if i need to change some registry value or java file handling etc for doing this, Thanks in advance.
If you use shortcuts in the Startup folder, then you can delete them by finding the reference to it via "%USERPROFILE%\Start Menu\Programs\Startup" then just do a File.delete(). You could write a *.bat file to do this for you too if it can't be done programaticaly in "Advanced Installer". If you want it to be a little more under-the-covers, the system also has startup items located in the registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Below is an example in regedit:
You can schedule task by executing next command:
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /d 15 /ru "System"
You can execute this command by Runtime.getRuntime().exec()
If it is a Java application I assume you are using the java launcher from Advanced Installer? If so, all you need to do is to create a shortcut for your EXE launcher and place it in the predefined folder "Startup" folder under "Start Menu" folder from Files and Folders page. The shortcut will be installed there when you install the package and removed on uninstall, and it will start your application when the machine boots the OS.

Launch Eclipse Program Exported From File

I already read many questions it the same subject, but none solved my problem..
I know that I can easly launch my app using this command on console java -jar myappname.jar
But what I want is to click on my .jar file exported by eclipse and it launches console with my app inside, do u understand?
I done the export using this configs :
File>Export>Jar File
Selected all the classes of my project
Selected "Export generated class files and resources"
Selected "Export java source files and resources"
Selected "Compress the contents of the Jar File"
Pressed Next
Selected "Export class files with compile errors"
Selected "Export class files with compile warnings"
Pressed Next
Selected "Generate the manifest file"
Selected Seal the Jar
And on "Select the class of the Application entry point:"
I choose my class where is the void main method .
the jar appears on my desktop, but then, when I double click it doesnt launch the console. why??
Thanks in advance!!
Launching a jar by double-clicking the file (or shortcut) will not display a terminal. One workaround is to change the default execute action in your operating system for .jar files to open a terminal and execute the command from within the terminal. A script like the following might do the trick (using Bash):
#!/bin/sh
/usr/bin/gnome-terminal -x java -jar $*
sleep 3
Then right-click on the jar file and choose the script as the default program to run for that file type.
Disclaimer: the above script actually fails for me. It works fine if the command being run in the terminal is "top", so it looks like you may need to tweak this a bit.
It depends on your OS.
If you use Windows, you can create .bat or .exe files. You can find 'how-to-create' tutorials on the internet.
If you use Unix based OS, you can just set the jar to be the executable.
A third party OS probaly has it's own way to set to executable.
This is the only way I am aware of.

How do I create a Windows-like clickable shortcut for Mac OSX?

I am helping a colleague set up some GUI programming tools I have written in Java.
I need to create a clickable icon to run the application which sets the current directory and then invokes the JVM, passing parameters to the program. Also nice would be to be able to use the PNG icon image I created for the program.
I suspect I need to create a script and somehow add that to the launcher strip that's across the bottom of the screen. Once off manual creation is all I need, not programmatic.
What's the right way to do this?
Use the Jar Bundler! With the Jar Bunder you can specify the Main class, any arguments, additional files and resources to the classpath, VM options and many more.
Have a look at this tutorial. There is also an Ant task available (not tried myself yet). If you have installed Xcode, it is located under /Developer/Applications/Utilities/Jar Bundler.app. The Jar Bundler itself is not public downloadable (except the ant task). I'm not sure, if the Jar Bundler is part of the standard Mac OS distribution. Start the terminal and have a look at /usr/share/java/Tools/Jar Bundler.app. You need an apple developer account to get Xcode if it is not present.
if you can do jnlp it will work in both mac and pc world
In OS X the closest thing to a shortcut that I am aware of is an alias. I'm not aware of any Java APIs for creating an alias directly, however you might consider invoking the ln -s command which creates a symbolic link, which is equivilant to an alias.
I can't confirm it works caus I'm on a PC but try
ln -s "/path to/your/app -arg1 -arg2" "alias name"
The OS X documentatiopn for the command is here

Categories