![]() |
| ||
| Interpreting JAR's launched with parameters Hey guys, I am trying to get some code to interpret a parameter determined by a JAR file. IE. C:\user\myProgram.jar 500 I want to know how to transfer 500 over to the program. I googled it, and most of the stuff that came up was extremely difficult to understand. Thanks PO |
| ||
| Re: Interpreting JAR's launched with parameters To tell you the truth, I don't know what you mean "interpret a parameter determined by a JAR file". If it is simply to be an argument on the command line, then, of course, args[0]. |
| ||
| Re: Interpreting JAR's launched with parameters args[0]? Sorry i am confused, here I will give you a small rundown of the program. I use a program to automatically log myself into Steam. With steam you can launch their games by saying C:\Steam\steam.exe -login username password -applaunch 500and of course the login and application vary between games. So I have a bunch of icons on my desktop that go to a JAR that logs me into steam automatically, but then I have to launch the game from inside of steam, so I want to know how to launch a JAR and have the jar grab the parameter. Basically I want to say C:\user\thatProgram.jar -500and have the program look for the parameter and if it's there make it a int inside of my program. Thanks Jon |
| ||
| Re: Interpreting JAR's launched with parameters Now if you have ever written a main, in your Java program, we write it as :- public static void main(String args[]) {Here the args, is an array containing the parameters you provided at the command line. Consider the following example :- public class CommandLineArgEx {Following would be the output that you will get :- stephen@steve:~/Development/java/daniweb> java CommandLineArgEx ABC Bcd Efg So as you see whatever is passed via the command line, is stored in the args[] String array. Although I have never tried it with a JAR, I do not see why it should not work. |
| All times are GMT -4. The time now is 4:47 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC