Results 1 to 5 of 5
  1. #1
    MrBambey is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default 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:

    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;
    	}
    The program must be rund from commandline with:

    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!

  2. #2
    corlettk is offline Member
    Join Date
    Apr 2009
    Location
    Brisbane
    Posts
    86
    Rep Power
    0

    Default

    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.

  3. #3
    MrBambey is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default

    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 11:11 AM.

  4. #4
    corlettk is offline Member
    Join Date
    Apr 2009
    Location
    Brisbane
    Posts
    86
    Rep Power
    0

    Default

    Quote Originally Posted by MrBambey View Post
    What do you think of netbeans GUI creator to do that?
    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.

  5. #5
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    Quote Originally Posted by corlettk View Post
    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.
    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 Boyo
    If 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

  1. How to make text bold using java
    By gundyguyz in forum New To Java
    Replies: 2
    Last Post: 07-28-2009, 06:06 AM
  2. Hints on how to make a Java Class
    By luron31 in forum New To Java
    Replies: 11
    Last Post: 07-09-2009, 06:31 AM
  3. Can anybody make this on java ???
    By eliCanzee in forum AWT / Swing
    Replies: 9
    Last Post: 04-30-2009, 02:14 AM
  4. Would this be easy to make in java?
    By tooner in forum Java Applets
    Replies: 3
    Last Post: 03-20-2009, 06:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •