Minecraft Blogs / Tutorial

Coding for Noobs! [Programming Tutorial Series] Tutorial 4: Exporting our Program

  • 380 views, 2 today
  • 4
  • 0
  • 12
999Destroyer's Avatar 999Destroyer
Level 44 : Master Technomancer
63
Welcome back all! 999Destroyer here with another tutorial. Today I'll be showing you how to actually make the "Hello" program we had last time into something we can run outside of Eclipse. The first thing we are going to do is go back to the program we had last time. It should look sort of like Screenshot 1.

Screenshot 1:

Image

Now that we have our program all ready to go, why don't we send it out into the real world? To do this, we are going to right click on our project folder (Hello) and click export [Screenshot 2]. We are then going to click "Java" and make it a "Runnable JAR file" [Screenshot 3].

Screenshot 2:

Image

Screenshot 3:

Image

Click next. Now you can choose where you want to save your folder [Screenshot 4]. When you are done that, click finish. It is OK if you have warnings.

Screenshot 4:

Image

Now we have our program ready to go! Try to run it? You will see nothing happen because the program is running in the background. What you want to do to actually show a console, is make a Batch file. When run, this file will execute our program for us with a console to work with. To make it do this we will first create a text file right where you saved your program called run. We will then go in and write the following inside:

java -jar Hello.jar
pause

This will execute our program. You must now save this file as a .bat file [Screenshot 5]. We can now delete our the .txt and when we double-click the run.bat, it should pull up a console with our program [Screenshot 6].

Screenshot 5:Image

Screenshot 6:

Image

Once the program is finished, you may press any key to exit. If this helped you please diamond and even favourite as it is very encouraging. If you want to see more, be sure to subscribe and leave comments below on what you want to see next! If you would like to join our development team, be sure to PM me. Thanks for reading and see you next time. Check out tutorial 5, coming out soon!
Tags

Create an account or sign in to comment.

1
01/27/2014 11:24 am
Level 31 : Artisan Dragonborn
jscooly555
jscooly555's Avatar
Just real quick, i am pretty sure .bat files don't work on mac. Maybe a .shell instead, i will edit this comment if it is!
1
01/27/2014 4:05 pm
Level 44 : Master Technomancer
999Destroyer
999Destroyer's Avatar
I believe it may be .command? Let me know if this works. In the next tutorial I will go over creating a console in the program before exporting it.
1
01/27/2014 8:33 pm
Level 31 : Artisan Dragonborn
jscooly555
jscooly555's Avatar
.command seems right, the only problem is that (even though I have done everything I can, and am the admin) it comes up with this: The file “Hello.command” could not be executed because you do not have appropriate access privileges.
1
01/27/2014 9:00 pm
Level 44 : Master Technomancer
999Destroyer
999Destroyer's Avatar
Hmmm... I personally do not use a mac but I'm guessing you should give the program or file itself administrator access?
1
01/27/2014 9:20 pm
Level 31 : Artisan Dragonborn
jscooly555
jscooly555's Avatar
tried that, didn't work. You know anything else XD?
1
01/27/2014 9:53 pm
Level 44 : Master Technomancer
999Destroyer
999Destroyer's Avatar
maybe try .shell? or you can access it easier with the cmd prompt
1
01/24/2014 6:52 pm
Level 40 : Master Ninja
Discostu97
Discostu97's Avatar
Could I ask you where did you learn coding in the first place ?
Awesome tutorials , also.
1
01/24/2014 7:03 pm
Level 44 : Master Technomancer
999Destroyer
999Destroyer's Avatar
Thanks! I mostly learn by myself. I spend a lot of time surfing the web, looking for solutions to any problems I've been having.
1
01/25/2014 7:40 am
Level 40 : Master Ninja
Discostu97
Discostu97's Avatar
Nice , I wanted to ask you about this because I know a couple sites where i learned JavaScript , Python , HTML and the like , but i just couldn't find anyone teaching Java , so your series of tutorials turns out to be very useful :3
1
01/25/2014 10:26 am
Level 44 : Master Technomancer
999Destroyer
999Destroyer's Avatar
I will also get into other, related languages, so let me know if you would like to know anything in specific.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome