juicyfasad.blogg.se

Mac executable file on double click
Mac executable file on double click











mac executable file on double click

mac executable file on double click

* One static method call will start a new instance of *THIS* application in the console and will EXIT the current * Created by Reddit user king_of_the_universe / StackOverflow user Dreamspace President / In case you have improvements (especially working command line strings for other systems), please let me know. In case the OS is not supported yet, a message window is shown saying that the program needs to be run from the console, incl. If not, it just returns.ĭetermines a command line string based on operating system (SO FAR ONLY FOR WINDOWS, but you just need to fill in the blanks) and then executes it with Runtime.getRuntime().exec(). When this other call is used, then if the executable name could not be determined (For which you can even give a fallback.), a message is shown (see below).Ĭhecks if nsole() returns null.

mac executable file on double click

If the first argument is "ide" (Case is ignored.), the method just returns. This should be reliable, but there is an alternative approach: A different call to the (overloaded) method allows you to hand over your main method's command line arguments. If this does not work, we must be in the IDE and hence have a console. jar file name of the running Java application is determined, and it's checked if that file actually exists in the current directory and if it is actually a file.

MAC EXECUTABLE FILE ON DOUBLE CLICK CODE

jar file in a new console and EXITS.Ĭreate class file AutoRunFromConsole and paste the below code under the package statement, replacing everything.Īs (one of) the first statement(s) in your main method, do nYourselfInConsole(true) (or false if you want the console to close once your application has ended). It just returns in case you have a console. It just returns in case you are in the IDE. It enables double-click start for standard Java console applications without altering the operating system or creating files. I left the printEnvironmentInfo() method in for assistance. It solves the problem for Windows, but users of other systems should be able to easily add what's necessary - I just didn't know the correct system command (if there is one). I had the same problem this morning, searched a bit, and create a static class from the available knowledge.













Mac executable file on double click