Help Please

Discussion in 'Programming General' started by Draucia, Feb 10, 2010.

Help Please
  1. Unread #1 - Feb 10, 2010 at 7:42 AM
  2. Draucia
    Referrals:
    0

    Draucia Guest

    Help Please

    I coded this Java program that opens with command prompt (no GUI or anything), and to run it, I open cmd and type

    "java C:\Users\xxxxxxxxxx\xxx.java".

    Is there someway that I can create a file (windows executable would be preferred), when clicked, will open that in cmd (or is there some other way to open it?).

    Please help me.
     
  3. Unread #2 - Feb 10, 2010 at 8:39 AM
  4. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    Help Please

    Open notepad. Paste that in. Save it has "run.bat"...
     
  5. Unread #3 - Feb 10, 2010 at 10:23 AM
  6. Draucia
    Referrals:
    0

    Draucia Guest

    Help Please

    It doesn't work. :(
    I put:
    java C:\Users\................\....
    and it doesn't work.
     
  7. Unread #4 - Feb 10, 2010 at 6:49 PM
  8. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Help Please

    What error do you get?
     
  9. Unread #5 - Feb 11, 2010 at 2:51 AM
  10. Molotov
    Joined:
    Aug 26, 2009
    Posts:
    149
    Referrals:
    0
    Sythe Gold:
    0

    Molotov Active Member
    Banned

    Help Please

    I've worked with java for a while, but I haven't made a executable file. Maybe save it as a .jar? or get a java compiler and maybe this should fix your problems.
     
  11. Unread #6 - Feb 11, 2010 at 8:15 AM
  12. Draucia
    Referrals:
    0

    Draucia Guest

    Help Please


    Well if I first type: cd [directry of .class file here], then type: java [file name], it works, but if I just type: java c:\users\xxxx\xxxx it doesn't work.
    I don't really need an .exe, just some way to open it without typing java then the class file name because other people who don't know much about java won't be able to do that. Do you know how I can get that into a jar file? I click export as a java jar, but it doesn't work when I double click.
    Oh and it's a console java application so it opens in command promt.

    I've tried saving it as a .jar, it doesn't work. And yes, I have a java compiler, thats how I compiled it into a .class file.
     
  13. Unread #7 - Feb 11, 2010 at 9:55 AM
  14. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Help Please

    Just type "java NAMEOFJAVAAPPLICATION" in the batch file, and save it in the same directory as your Java file.
     
  15. Unread #8 - Feb 11, 2010 at 5:19 PM
  16. Draucia
    Referrals:
    0

    Draucia Guest

    Help Please

    Yeah thanks that worked, but is there some way I can package that into one file like a .jar file or maybe even .exe?
     
  17. Unread #9 - Feb 11, 2010 at 6:42 PM
  18. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

  19. Unread #10 - Feb 11, 2010 at 8:02 PM
  20. Molotov
    Joined:
    Aug 26, 2009
    Posts:
    149
    Referrals:
    0
    Sythe Gold:
    0

    Molotov Active Member
    Banned

    Help Please

    Ok, you can do it like a rsps private source. Just read the batch files in those.
     
  21. Unread #11 - Feb 11, 2010 at 9:27 PM
  22. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Help Please

    And how do you think they do it..?

    @OP Why not just import your code into an IDE like Eclipse, or IntelliJ and have that export the jar for you (coding within an IDE really speeds up development time)?
     
  23. Unread #12 - Feb 11, 2010 at 9:33 PM
  24. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    Help Please

    ^That is your best bet.
     
  25. Unread #13 - Feb 12, 2010 at 3:45 PM
  26. Draucia
    Referrals:
    0

    Draucia Guest

    Help Please

    I don't really get that. There is one for class, which I have, and there is a option for main class or something. What is that going to be?

    Umm.. I don't really get it. o_O

    I made it in Eclipse, and when I export the .jar file and double click it, nothing happens. Did I mention this is a console application that opens in command prompt?

    Okay


    Thanks for taking the time to help me. :)
     
  27. Unread #14 - Feb 12, 2010 at 4:02 PM
  28. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Help Please

    Oh, so the problem isn't that it doesn't run (it does run), but you don't see the output because the console isn't visible.

    Type:
    Code:
    @echo off
    java -jar JARNAME.jar
    pause
    
    And save it as run.bat in the same directory as your .jar file (change JARNAME.jar to the name of your jar, of course). Double click run.bat and it should run with the output visible. Then to update, simply replace the old jar with the new one.

    I do recommend, however, giving your application a GUI (Graphical User Interface) so that they can see the output in a nice window instead of in command prompt/terminal.
     
  29. Unread #15 - Feb 12, 2010 at 6:02 PM
  30. Draucia
    Referrals:
    0

    Draucia Guest

    Help Please

    Thanks, but isn't there some way I can package it into 1 file that I can send to someone. And also, I do not know how to make a GUI yet, I'm still learning. Or is it not hard and you can tell me now?
     
  31. Unread #16 - Feb 12, 2010 at 6:14 PM
  32. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Help Please

    No. Because you're doing System.out.println()'s to show the user data, you must run it in terminal, so it has to be more then a single file.

    As for making a GUI, you should take a look at Sun's Swing Tutorials.
    http://java.sun.com/docs/books/tutorial/uiswing/
     
  33. Unread #17 - Feb 12, 2010 at 6:34 PM
  34. Draucia
    Referrals:
    0

    Draucia Guest

    Help Please


    Ok thanks, at least I got it working. I'll look at the tutorials, but I think my PDF tutorial will be better for me.


    EDIT: Ugh it says failed to load main class manifest.
     
  35. Unread #18 - Feb 13, 2010 at 9:09 PM
  36. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Help Please

    When you're exporting the jar in eclipse, don't press the finish button as quickly as you can, press the next button until the final screen. On that screen, you must select the main class of the jar file (this is the class with your main method which will be called by the JVM to start your program). Once you do that, you can hit finish.
     
  37. Unread #19 - Feb 14, 2010 at 2:14 PM
  38. Draucia
    Referrals:
    0

    Draucia Guest

    Help Please

    The "Next" button is disabled. What should I do?
     
  39. Unread #20 - Feb 14, 2010 at 2:52 PM
  40. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Help Please

    Hit finish after you select the main class.
     
< Question | i need a mass email account creater >

Users viewing this thread
1 guest


 
 
Adblock breaks this site