Hey Dog,
Learning a bit of java at the moment.
I wrote a small app that simply will take input from a user for the radius of a cirlce then spit out the Area, circumference, and diameter. Here is my code. But what I'd like to do is compile it as an exe or i'm thinking .jar file so I can simply run it in an OS environment. Can you point me in the right direction on how to do this. Doesn't seem my app "eclipse" can do this or at least I'm not seeing it. Here's my code.
<br /> /***********************************************************************<br /> Program Name: Circle.java<br /> Programmers Name: Glen Ciszewski<br /> Program Description: This program will calculate the area, circumference and diameter of a circle<br /> ***********************************************************************/<br /> import javax.swing.JOptionPane;<br /> public class Circle <br /> {<br /> <br /> <br /> public static void main(String[] args) <br /> {<br /> String userInput; //number entered by user<br /> int radius; //converted input for number<br /> double diameter; //the diamater of the circle<br /> double circumference; //the circumference of the circle<br /> double area; //the area of the circle<br /> <br /> //read in the users input as string<br /> userInput = JOptionPane.showInputDialog("Enter in the radius");<br /> <br /> //convert number from string to type int<br /> radius = Integer.parseInt(userInput);<br /> <br /> //find the diameter<br /> diameter = 2*radius;<br /> <br /> //display the diameter<br /> JOptionPane.showMessageDialog(null,"The diameter is " + diameter,<br /> "Results",<br /> JOptionPane.PLAIN_MESSAGE);<br /> <br /> //find the circumference<br /> circumference = 2*Math.PI*radius;<br /> <br /> //display the circumference<br /> JOptionPane.showMessageDialog(null,"The circumference is " + circumference,<br /> "Results",<br /> JOptionPane.PLAIN_MESSAGE);<br /> <br /> //find the area<br /> area = Math.PI*radius*radius;<br /> <br /> //display the area<br /> JOptionPane.showMessageDialog(null,"The area is " + area,<br /> "Results",<br /> JOptionPane.PLAIN_MESSAGE);<br /> System.exit(0);<br /> <br /> }<br /> <br /> }<br />
those Html breaks aren't really in my code. When I placed it in between the code tags in the post they got added automatically. Guess i didnt' need the code tags but most forums like you to use them. I'm new to programming but not quite that Green My code works but just wanted to make it something I could run outside of my dev software.
I thought I could export the project as an executable .jar file but that don't seem to be working. I'll figure it out.
Thanks.
I hope that after I die, people will say of me: "That guy sure owed me a lot of money.''
Good read. thanks GG
I hope that after I die, people will say of me: "That guy sure owed me a lot of money.''
A little. I didn't have time to read it all yet. I'm swamped at work. And I'm still trying to let it all soke in being new to the programing thing.
I hope that after I die, people will say of me: "That guy sure owed me a lot of money.''
Thanks, Yea I know what you mean. It can really give you a headache. I just wish I had more time to sit down with it and do it. Alway's wanted to learn programing. At least these classes make me do it. There only 8 weeks long though. So really how much can you learn in an 8 week class when it comes to programing?
Well I've had enough fun at work. now off to class for me!
TTYL
I hope that after I die, people will say of me: "That guy sure owed me a lot of money.''
Olympus
Single & Not Looking
First you need to strip out the html code in it (the breaks) and then just need to compile it with a java compiler (the JDK). "Compiling" runs it through the java interpreter and converts the code into an executable file.
After it's installed and added to your Windows path, you can just go to the command line and type: javac Circle.java
Then to run it, after it's compiled type: java Circle
You should be able to add the compiler to Eclipse so it can compile it for you with a button click once you have the JDK installed, since it's a commandline tool.