Results 1 to 5 of 5
Thread: Java: Make runnable java-file
- 08-08-2009, 12:14 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 2
- Rep Power
- 0
Java: Make runnable java-file
Hey there,
I've got a java app sofar, which works great via commandline. If there are no arguments passed, it runs in interactive mode which means that I'm printing text wiht System.out.println() and reading users input via:
The program must be rund from commandline with:Java Code:public String readString() { InputStreamReader input = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(input); String str = ""; try { str = reader.readLine(); } catch (IOException e) {} return str; }
java -jar program.jar
1. I'm wondering how to do that the program gets interpreted directly by simply typing program.jar? Is there a way to or do I always need the "java -jar" in front?
The second way of using it is something with arguments like
java -jar program.jar -bla -foo
Then there might (depending on the arguments) an output via System.out.println() or not.
2. My second question is how to extend the functionality to have a GUI with some checkboxes and one or two (the second input-box is only needed when activating another checkbox) textfields when opening the program by double-clicking it? The functionality (inteactive mode in command line or mode to use command line arguments) should not be changed and should be preserved, so that there's a third way of using the program!
Thanks so far!
- 08-09-2009, 09:51 AM #2
Member
- Join Date
- Apr 2009
- Location
- Brisbane
- Posts
- 86
- Rep Power
- 0
1. Of course there is... but (of course) it involves tricky, non-standard, naferious means, so don't bother... I advise you to just stick with typing the "java -jar".
If you run program.jar at lot then you could create a script to compile and run it (with the given parameters)... exactly how you do that depends on which O/S you're running.
2. Of course you can... But... Java GUI programming is a bit more involved than most noobs are ready to deal with... So I strongly suggest you steer clear of GUIs until you have a good grasp of "the basic language", OO principles, and multi-threading.
If you really can't wait then start here, and good luck to you.
Cheers. Keith.
- 08-09-2009, 10:02 AM #3
Member
- Join Date
- Dec 2008
- Posts
- 2
- Rep Power
- 0
OK thanks for your reply. Nice to hear that it's possible.
1. Ok if you tell me it's non-standard, than it's not really important. I was just wondering :)
2. Ok thanks so far. Perhaps I'm gonna try out a little program with a simple GUI and than try to implement it into my source-code. What do you think of netbeans GUI creator to do that? :> Edit : Just saw the netbeans gui creator showed in your link, so thanks :)Last edited by MrBambey; 08-09-2009 at 10:11 AM.
- 08-09-2009, 10:27 AM #4
Member
- Join Date
- Apr 2009
- Location
- Brisbane
- Posts
- 86
- Rep Power
- 0
NB's Matisse is the current "best of breed" Swing GUI creator, but my advise is DO NOT use it. You need to actually understand How It Works before you can use the tool to generate anything useful, but the tool hides the details from you, so IMHO the tool is fundamentally a no-no for noobs... but then again I think GUI's are over noobs heads... but that's exactly what every kid wants to rush into, and most of them EPIC fail... but if you must, you must.
Cheers. Keith.
- 08-10-2009, 06:40 AM #5
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
I am, quite literally, a 'kid'. And I used GUI's from about my third program onward. While complex GUIs were by far over my head, simple ones with one or two buttons and a couple of TextAreas and Labels were fine. Just avoid using complex LayoutManagers, and make sure that you have the code behind the GUI working correctly before you try to create a GUI.
My suggestion is that you use BoxLayout/FlowLayout, and just create as many JPanels or containers as you need.
Best of Luck,
Singing BoyoIf the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
Similar Threads
-
How to make text bold using java
By gundyguyz in forum New To JavaReplies: 2Last Post: 07-28-2009, 05:06 AM -
Hints on how to make a Java Class
By luron31 in forum New To JavaReplies: 11Last Post: 07-09-2009, 05:31 AM -
Can anybody make this on java ???
By eliCanzee in forum AWT / SwingReplies: 9Last Post: 04-30-2009, 01:14 AM -
Would this be easy to make in java?
By tooner in forum Java AppletsReplies: 3Last Post: 03-20-2009, 05:55 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks