Question:
Need more help with Java. How to run a program I made?
2006-12-01 15:41:10 UTC
Ok, I have a basic progam made, I know it'll work because it is from a basic tempalte from a book. I did it in notebook, saved it as a java file, but now how do I run it?

On my last question someone suggested using Eclipse for something, but I'm not sure exactly what it is for, and I' rather not because of the size and my dial up speed.

I have WIndows XP, how do I run a Java program. Please, assume I'm clueless and you'll probably not be far off. My instruction book... assumes a LOT.

Thank you
Four answers:
zak_track
2006-12-01 16:13:02 UTC
First let's make sure you have the correct setup. I'm guessing you don't have a java compiler, but here's how you check. Click Start->Run and type cmd. In the window that pops up, type "which javac". The location of javac (the java compiler) will pop up if you have it, otherwise it will give you a blank line. If you do have it, you can skip the next paragraph.



Go to http://java.sun.com/javase/downloads/index.jsp and click the Download button to the right of "JDK 5.0 Update 10". Accept the licence agreement then click on "Windows Offline Installation, Multi-language". When it finishes downloading, run it and it will install java.



Now that java is installed, you can run your program. Let's assume your program is called myProg.java and it's located at C:\programming\myProg.java.

Open up the command line (Start->Run, type cmd). Change directory to the directory where your program is located. You do this by typing

cd C:\programming\

(yours will be in a different place, so fill in the path accordingly)

Compile the program by typing

javac myProg.java

Then run by typing

java myProg



Good luck!
zypher1083
2006-12-01 16:07:50 UTC
First you need to make sure you have the proper Java tools installed. You need the Java Software Developer Kit (SDK) not just the Java Runtime Environment (JRE). You can download both the SDK and JRE from http://java.sun.com - The JRE is included in the SDK download.



Next you need to compile the program you wrote.

1) Make sure you save the file with a '.java' extension - take note of the location you saved it in.

2) Go to Start-->Run and type 'cmd' this will bring up the command prompt.

3) cd to the directory that you saved your '.java' file in (i.e. cd C:\path\to\my\file



Now for the rest we are going to assume your class name is HelloWorld



4) type 'javac HelloWorld.java'

5) type 'java HelloWorld



That should allow you to run the program that you have made.
munsy
2006-12-01 15:52:22 UTC
Wow. This is a much bigger question than you may think. First you will need to compile your program, probably with "javac". Once it's compiled, you can run it with a program called "java". (This of course assumes that you have download the Java IDE from http://java.sun.com)



A program such as Eclipse (or NetBeans) can be used to create, compile, and run your programs from the same interface.



There are a lot of good tutorials online. Check http://java.sun.com for some.
asep_sidhi
2006-12-01 15:57:02 UTC
OK, here's how I do my java.

Tools :

1. Textpad (torrent at: http://www.mininova.org/get/319058)

2. Java 2 SDK&JRE (at: http://java.sun.com/j2se/1.4.2/download.html)



Things to do :

1. Install J2SE SDK & J2SE JRE

2. Install Textpad.

3. type your program using textpad.

(in here you should know about your script. Ist it Console base ? applet base? regular form base?)

4. Compile your script using Ctrl+1 - for Console base, Ctrl+2 - for regular form base, Ctrl+3 - for applet base.



Well that's all I used to do.



Fell free to contact me ^_^


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...