Free Native Launcher For Java At Linux and Mac - java

My Java application require a huge memory heap. I need to launch my application using
java -Xms32m -Xmx128m xyz.jar
Hence, I would like to create native launcher for my Java application, where I can pass the JVM heap size parameters in. I plan to use JSmooth http://jsmooth.sourceforge.net/ for Windows platform.
However, I would also like to create native launcher for Linux and Mac. May I know which open source/ free software can help me to do so?
LaunchAnywhere
http://www.zerog.com/iamanual/usermanual_ia55/WebHelp/launchanywhere/abo12e.htm
seem good. But it is a commercial software.
Thanks.

This may not be the answer you want, but I would use an application bundle on MacOS and a simple shell script on linux/unix.
Only reason really is that the end user experience of using web start and or shell scripts on OSX just isn't that great, Mac users expect everything to work like a Mac app bundle.

Hm, you might consider using Java Webstart. It's a bit more than just a launcher, but it can do the things you want. It eases deployment, and you can also install applications manually and use them offline, and it's cross-platform.
Or you can just write a simple launcher shell script. Many apps do that, and it works fine.

Use '/Developer/Applications/Utilities/Jar Bundler' to package your Jar as a Mac app. This makes it easy to specify an icon, launch params for heap size, minimum Java versions, System properties, etc.

Related

Does Java Program on XP will run as it is on windows 7

I wanted to know Will the Java desktop application running on Windows XP also run as it is on Windows 7 or need any modification in program?
Theoretically java is platform independent and should run on any Windows, any linux, any mac etc without any modification exactly the same. Practically you have to check that you do not use any platform dependent features or parameters.
For example:
JNI
Execution of platform specific command line tools
Platform specific file paths
Communication with platform specific processes/services
Operations that can produce security issues on some Operating systems (e.g. specific file paths, registry entries under HKLM on windows 7,8 etc)
Assumptions about line, path, file path separators (\r\n vs \n, \ vs '/', ; vs :)
Wrong usage of layout managers that can cause UI to fail on some screen resolutions.
Yes. It will definitely work. Try it and if got any errors send us for review.
Java is Platform Independent.
You can use that application in any OS.
In stand alone application, Java source code is converted into byte code . So Java is platform independent.
Java's claim is to be a WORA (Write Once, Run Anywhere) language.
Assuming that Windows 7's JRE hasn't introduced any new bugs and assuming your code is straight-forward Java that doesn't rely on JNI, manipulating Windows XP specific registry keys, etc., the answer is a definite yes. It should run smoothly.
Yes, thanks for the JVM (Java Virtual Machine) it will act the same on different platforms ...

How to test Java Desktop Application with diffrent Platform

I have develop on desktop application in java.
Now problem is that now i want test that application with different platform like
windows,Linux,MAC with 64bit and 32bit Os Comparability.
Another big issue is that i want to test maximum Java JRE version like 1.5 to 1.7.
How can i test my application?
Is there any tool available which help me solve this issue?
To test on various operating systems, use a virtual machine like VirtualBox (free). Linux is free to get, but you will have to pay for other OSes. Mac doesn't like you installing it on anything but a Mac computer, so you might have to hack that, or buy a Mac. But you do have to set up a new environment every time. The testing wouldn't work otherwise, different operating systems are very different.
It's easier to test different JREs, check out the answers for this question: Setting the JVM via the command line on Windows

Run Java Threads On One CPU

We Have a Multi-threaded Application in JAVA which has multiple threads running in parallel. Now we want to run all these threads on a single core. Currently application is running on a system having more then one Cores.
We know there is a technique available ProcesAffinity in .Net Framework to set process affinity.
But we don't want to depend on .Net Framework, because our application is build in java.
Do we set Process affinity using Bat file and run our application executable jar file through Bat file?
Currently our application is running on Window XP. So we need a solution that should be working fine on XP platform.
EDIT:
It's possible: See Java thread affinity
Pure Java doesn't support running a thread on specific processor. Check the SO question linked above.
Personally, I don't think that the fact that this cannot be set in pure Java is a bad thing, as to me, how an app is run does very much depend on the OS, so therefore a OS-specific solution isn't a bad thing.
You can use the MS psexec utility to set the affinity:
psexec -a 1 java -jar myapplication.jar
Would instruct that all of the threads created by java would be run on the lowest CPU.
And this line would be your .BAT file...
You cannot do it in pure Java. But on some versions of Windows, you can do it via operating system utilities; see https://superuser.com/questions/309617/how-to-limit-a-process-to-a-single-cpu-core ... and you might be able to do this by calling native libraries via JNI.

Difference between 'java' and 'libjvm.so' (Linux) or 'jvm.dll' (Windows)?

What are the differences in starting an application through the plain java command, against directly invoking the JVM through libjvm.so in Linux or jvm.dll in Windows ?
Recently I saw on a forum that starting eclipse using the dll or .so file will give better performance. I would like to get to know how this happens.
Thanks.
Typically folks build against jvm.dll if they want to wrap their own functionality around a Java core, where sometimes it's hard to do things that look "native" from Java. A good example is indeed Eclipse, where they want to pop up a splash screen and do some other actions before starting up. For other products, it's that Java is only a small part of their workload (eg: large C++ app that needs to bridge into Java at some point).
From a performance perspective, it's irrelevant. It's all about how you want the "fit and finish" for things like Eclipse.
The link discusses Eclipse start-up; it is likely that this is faster because, by using the -vm argument to specify the JRE, the Eclipse executable doesn't have to search the system for an appropriate JRE to launch (which would incur disk I/O and possibly involve detecting the version of the JRE). You aren't speeding up Java, you're speeding up the native launcher.

How can I give my Java application a unique process name?

I've noticed that when I start Netbeans it shows up in the task manager as netbeans.exe as all my own Java applications show up as java.exe or javaw.exe.
How can I change that so my process names shows up as myapp.exe?
The process name is the name of the JVM. So if you rename the jvm you have an other process name. There are some tools which can do that for you. For example Launch4J
IMO the best option is to choose one of the many open source launchers. They all provide a nicer deployment container than java.exe and a batch file.
I've compiled a list of them after a brief search on google (in no particular order and may not be exhaustive):
NSIS
Janel (dead link)
JSmooth
Launch4J
WinRun4J
(full disclosure: i work on winrun4j)
Not easily. The easiest way (but not nice!) would be to simply copy the java.exe (only 68k on my system, so perhaps practical!)
If you're worried about identifying which java process is which (e.g. is one consuming memory/CPU etc.), use the standard tool jps to identify the Java processes
Netbeans and Eclipse both ship with an .exe file that in turns launches a JVM. The exe itaself probably does nothing after launching the VM. You see the NetBeans javaw.exe in the Task Manager also, I suspect.
So you'll need to write a native exe (using some windows tool) that does a similar thing.
Just answered this a second ago here: Get JVM to grow memory demand as needed up to size of VM limit?
It's actually a lot easier than folks are saying (but you do have to have a c/c++ compiler handy).
There are mainly 2 approaches: one is as already described: using tools like Launch4j, WinRun4J to create native Windows launchers.
Another approach that seems better is to use Apache Procrun to wrap the java application as a Windows service. During the install service process, we can give the process an meaningful name such as OurApp.exe.
All we need do is rename prunsrv.exe to OurApp.exe and replace every occurrence of prunsrv.exe in our install|start|stop|uninstall service scripts to MyApp.exe.
See more from Using Apache Procrun to Rename Process Name of a Java Program in Windows

Categories

Resources