Hi

Can anyone please tell me whether I can write a java program and start it in a way other that involves the command line? And not applets either.

I want to start writting all of our company software in java, leaving behind c#. But the problem is I can only run java programs from the command line using the java command. End users will not like this.

Is there anyway to make java programs more user friendly By providing a shortcut on the desktop and adding it to the start menu.

Thanks in advance
Rav Wolf

Dani AI

Generated

Short summary and context from the thread: the answers here are on the right track — Java apps can be started like any other program (desktop shortcut / Start menu); you do not have to force end users to type commands. and correctly pointed at creating distributable JARs, and touched on wrappers, and raised the important packaging/installer option. Below are practical, current options and tradeoffs to pick from depending on how the app will be deployed.

For a supported, production-ready distribution that creates native installers and a real Start‑menu/desktop shortcut (and can bundle a runtime so users don’t need a preinstalled JVM), use the JDK packaging tool (jpackage). It produces platform-appropriate packages (Windows EXE/MSI, macOS PKG/DMG, Linux DEB/RPM) and creates native launchers. This is the recommended starting point for corporate desktop apps. (openjdk.org)

If size matters, build a custom runtime image first with jlink and then package that image. jlink lets you include only the JDK modules your app needs (smaller footprint, fewer CVE surface area) and is intended to be used together with packaging tools. Test the result on a clean VM to make sure no modules were missed. (docs.oracle.com)

If true native binaries are required (faster startup, no JVM dependency), consider ahead-of-time compilation with GraalVM’s native-image. It produces standalone executables but requires configuration for reflection, dynamic proxies, JNI, etc., so there is extra engineering cost and some libraries may need adaptations. Use it when startup latency or memory matters. (graalvm.org)

For simpler or legacy workflows you can wrap a JAR in a Windows EXE (Launch4j/Launch5j/JSmooth) and ship an installer (Inno Setup, WiX, or similar). Wrappers are quick but have trade-offs versus true bundling: larger installers, handling JRE discovery/versioning, and signing/SmartScreen issues to manage. For corporate rollouts, prefer OS-native packages + code signing and automated deployment (SCCM, GPO) rather than asking users to run a binary manually. (launch4j.sourceforge.net)

Practical checklist before shipping: pick whether to bundle a runtime; test installers on clean VMs of each target OS/version; sign installers/executables; document update strategy (self-update vs. reinstall); and run automated tests for startup, file associations, and permissions. These steps address the end‑user friendliness you want while avoiding the “type this into a console” experience.

Recommended Answers

All 8 Replies

Yeh compile it and use the *.jar file. All the java command does is compile it? Could be wrong here.

I am not sure if you are right.

the javac command compiles it. the java command starts the virtual machine, load the specified class and invoke function main. in other words its the same as clicking a program icon on the start menu.

Hi Rav Wolf ,
when you compile your java code , a .jar file is created .. then you can use any of the progras that converts jar to exe such as "installJammer" , InstallJammer creats a .exe file from the .jar file ..

I hope i helped you ..
any question i'll be there .

thanks

best regards.
eng.Hosam

thanks. i'll go check it out. will get back to you hopefully soon. thanks again.

.
thanks to you too. it seems you were on the right track.

cheers

Hi Rav Wolf ,
when you compile your java code , a .jar file is created .. then you can use any of the progras that converts jar to exe such as "installJammer" , InstallJammer creats a .exe file from the .jar file ..

I hope i helped you ..
any question i'll be there .

thanks

best regards.
eng.Hosam

when you compile, a .class file is created. not everyone uses an ide which automatically generates .jar files. a.jar file is basically a structured .zip file, used as a executable file for java progs

If you want to create a jar very easily, one way you can do it is by using the Eclipse IDE. To create a jar in eclipse,

file-> export -> Jar File (this might be listed under 'java' -> next, and under manifest class you would select the main class that you want to run when the program is started,.

There is no reason you need to create an .exe from the jar file (and many reasons not to). Just read the tutorial on packaging applications as jar files: http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

For your shortcut, you can simply use the same syntax that you would to run it from the command line. If you don't want the command window to persist while it's running, use "javaw" instead of "java"

javaw -jar MyApp.jar

. You can add any switches you might need.

If you want to provide an installer for the app, you might take a look at IzPack.

hi. ! can anybody tell me how can i construct menu in a simple java program..in which i use switch statements for addition,multiplication and subtraction purposes. i will be very thankful to u..... shruti thakur.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.