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.
Related
I have installed a Java Application[which creates slides presentations like powerpoint] on my computer. It runs successfully from start menu. But when I Open the file created in that application, it does not opens, application does not launches. Somehow those files can't find the path to that application. does anyone have any idea what possibly could be the issue? I am using windows 7.
Windows uses file associations to know which application can handle which file type.
These associations aren't created by magic; either an installer creates them or you need to create them manually. When you right-click the file and select "Open", Windows should ask you which application to use. Select your Java app and it might work.
"Might" since some applications don't accept command line arguments. That means Windows can't tell the app which file to open. If that's the case, then you need to launch your app manually and then open the file from within the app.
Related:
Add a new file association in Windows 7
This likely isn't possible, but I thought I would ask just to be sure. I have a batch file which starts my java app using relative paths. Ie. i have:
Application\start.bat
Application\lib*.jar
My application creates a configuration file in the Application directory. My batch script uses relative paths to point to the lib directory jars. This has worked really well for me because I can move the program wherever I want and it will just run. However now I would like to be able to call the same app from command line as well not just from a shortcut which has the working directory set to Application. The problem is that I want to be able to call my application from any directory on the command line and right now this doesn't work because the working directory will be different.
I know I can always add another parameter to my app for the working directory but then I still have to create a batch script with a hard coded path to my application. Is there any way around this in Java, for example to get the directory that my main java file is in on top of the working directory? Is there a launcher app perhaps?
I can't bundle my app as a jar because it creates configuration files which I want to be in the same directory as the application.
Consider just changing current dir in start.bat:
#cd /d %~dp0
java ...
This would change it to the folder where script is located.
pushd/popd commands can also be used to preserve current dir for calling script if needed.
Alternatively getClass().getProtectionDomain().getCodeSource().getLocation() can be used from java to get path to jar/classes.
There is also path-independent approach with config path system property:
java "-DconfigDir=%~dp0" ...
There is no portable solution that is going to work in all cases. Indeed, the notion of an application directory does not necessarily make sense; e.g. consider applets and applications launched using WebStart.
If the notion of an application or installation directory does make sense, then the simplest way to support it is to have the application's launcher / launch script pass it to the application Java code via an application specific -D property.
I'm into a very strange issue that's making me crazy .-.
I'm working on a relatively big Java project on Windows, using NetBeans and IzPack to prepare the graphical installation package.
Everything is ok, the compiled installer seems to work and my program is copied in 'C:\Programs\MyProject' folder.
But... when I double click on the myproject.jar in that folder it doesn't start at all. I obviously tried to open a prompt and type 'java -jar myproject.jar' but nothing, not even a line of error code.
The curious facts are two:
if I open it using the prompt with administration rights it works
in the same folder there is another jar, 'uninstaller.jar' created by izpack, and it works with double click.
I double checked my JVM installation, the PATH/JAVA_HOME/... values, and Properties->Security tab of my JAR but the permissions to execute/read/write for every kind of user are ok, and also are equal to the uninstaller.
So what's the problem? Thanks
This is almost certainly caused by Windows UAC on Vista and Windows 7.
Your program is probably trying to write to data files in the same directory as it is installed.
On Windows, well behaved programs write to the users or all users app data directory.
The location of that directory varies depending on the version of Windows.
You can use the system property "user.home" to find a safe place to store data.
You can also get a list of environment variables for shared and per user program data folders from here.
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
Without learning new programing languages, can we using Java get .exe (executable windows file) software directly? And is there away to make .jar (Java ARchive) software transform to.exe (executable windows file)?
Would this conversion effect the performance of the software?
One of the important points of Java is that it'll run on any platform (e.g. Windows, Linux, etc) that has a suitable Java Virtual Machine (JVM) installed. A .exe file is compiled to work on only one platform.
What you think you want is to turn a .jar into an .exe so you can launch it easily. What I expect you really want is just an easy way of launching a Java app that anybody can understand, including your parents.
The easiest way of doing this is to create a Windows batch file that launches your Java app. One of line of script, one new file, one new instruction to your users - "Double click on runme.bat"
There are ways of turning a .jar into an .exe, but you should think about whether that's really what you want, and if so, why.
Note: you can launch a .jar in Windows by just double clicking on it, as long as the main class is specified in the manifest. You might want to look into tools like Apache Ant to simplify building .jars and their manifests. Just a thought.
EDIT:
A batch file in Windows is a simple text file that contains commands. You can test the commands by running them in the command prompt (Start -> Run -> cmd). When you run a batch file the commands in it are just fed to the command prompt one at a time.
How to run a Jar from the command prompt: "java -jar myfile.jar"
If you create a batch file (.bat - use Notepad or your favourite text editor) containing "java -jar myfile.jar" (without the quotes!) then double-clicking it will launch the main class specified in the manifest of myfile.jar. myfile.jar has to be in the same folder as the batch file, though.
If you use the command "java -jar lib\myfile.jar" (again, without the quotes) then your batch file will run myfile.jar, which needs to be in a folder called lib that's in the same folder as the batch file. Use this approach when you have a whole load of Jars with your application and you don't want to shove them in the user's face :)
Note that moving the batch file will break it, unless it uses absolute paths to the jar file - e.g. "java -jar C:\dev\myfile.jar". Of course, if you use absolute paths then moving the Jar will break the batch file anyway :)
Also, note that you should be able to run a Jar file just by doubling clicking on it in Windows, as long as the main class is specified in the manifest. Give it a try. Of course, convincing your users that they can double click on it is another matter entirely...
As a final note, if you use a batch file, your users will get a nice command prompt window sitting in the background until your Java app closes. That is, unless you start your batch file command with "start". E.g. "start java -jar myfile.jar". If you have your app configured to log to System.out or System.err, you will still get a command prompt when your app writes to either of those streams, though.
Final final note, in the Linux world the equivalent of batch files are shell scripts.
You can launch a .exe from java with Runtime.exec() or ProcessBuilder.
You can make a .exe launcher with http://launch4j.sourceforge.net/
Yes, it is possible: http://www.excelsior-usa.com/articles/java-to-exe.html
I'm not sure if this is an appropriate answer because I don't work with Java but could you not using a shortcut file pointing to the java runtime and pass the jar as an argument, this
I realise this is not the only way, nor probably the best way but to me it seams a little better than creating a batch or converting to an exe file if all you're looking for is a convienient way to launch a java app
The very simplest way is to write a windows batch (.bat) file which will start the application.
I was using a wrapper for java to make exe files for a pretty long time:
JStart32
It is just a wrapper for *.jar files.
But ask yourself:
Wouldn't an exe kill the purpose of javas platform independency?
Check out jsmooth (free) and exe4j and you might want to read make your swing app go native