Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

how do u compile a prog?

  Asked By: Kerri    Date: Feb 03    Category: Java    Views: 722
  

I know it sounds really stupid.
But I seriously know nothing about computers. How do
you compile a java program? I got some instructions
from my teacher but did not understand a thing! I
tried using J++ (even though i'm not supposed to) but
the problem is, it closes the output window right
away so I don't have time to copy it. Does anyone have
an easy way of compiling?

Share: 

 

9 Answers Found

 
Answer #1    Answered By: Agatha Miller     Answered On: Feb 03

I use MS J++ at work and you shouldn't have a
problem compiling if you put your file in a project. Once
in a project, choose the Build option on the toolbar
and select Build (or just hold down Cntl+Shift+B). If
you wish to compile  and run it outside of the editor,
go to the MS-DOS Prompt. Map your way to the
directory where the .java file is. Then type: <br>javac
[filename].java <br>If you compile with no errors, another prompt
will appear. To run the program, type:<br>java
[filename]

 
Answer #2    Answered By: Sonya Flores     Answered On: Feb 03

To compile  a java  program, at the command line
type:<br>javac filename.java<br><br>For example, given the file
MyFirstClass.java<br>which contains:<br>class MyFirstClass<br>{<br> public
static void main(String[] args)<br> {<br>
System.out.println("Hello World");<br> }<br>}<br><br>to compile at the
command line type(case sensitive):<br>javac
MyFirstClass.java<br><br>to run at the command line type:<br>java
MyFirstClass<br><br>and you should see the phrase<br>Hello
World<br><br><br>There is lots of good information at
http://java.sun.com especially the
Java Tutorial section.

 
Answer #3    Answered By: Eric Foster     Answered On: Feb 03

To help you, you should also tell us what
computer system you are using, i.e OS and environments.
Supply this info:<br>Intel based, Mac -- Window 9x, Win
2K, Linux. To better help you, the mentioned
information should also be included. The help you've been
given is sufficient, but I've found that for most
beginners they neglect to give the above info and the help
they receive will not work on their computer
environment.

 
Answer #4    Answered By: Oliver Evans     Answered On: Feb 03


Thanks. I managed to do that once but then I
forgot what I did. Now I'm trying to do it again but
it's adding the form1.java to the project
automatically. So if i compile, it gives me a blank form. If i
delete the form from the project, it gives me an error.
I hope that makes sense! I remember that when it
did compile, the window closed right away. So I was
not able to copy the output. Is there a way I can
keep the window open as in C++?

 
Answer #5    Answered By: Geb Chalthoum     Answered On: Feb 03

I tried this. but this is what it's giving me
:<br><br>'javac' is not recognized as an internal or external
command,<br>operable program  or batch file.<br><br>do I need to d/l
any programs for that or what

 
Answer #6    Answered By: Corey Brown     Answered On: Feb 03

It's a PC with a Win 2K....................

 
Answer #7    Answered By: Fred Hicks     Answered On: Feb 03

you need to set the path to Java's JDK?
directory. Substitute the ? with the version of the JDK on
your machine(the directory's name). Once you set the
path in the environment variables you will be able to
compile and run any .java file from any directory. I
think the problem you're having is setting the 'path'.

 
Answer #8    Answered By: Angel Watkins     Answered On: Feb 03

I finally managed to
compile it. Now I have another question. how do you type
cast in Java? let's say u have Cost = Quantity *.8763
(float, float, and double, respectively). what should u
put in front of the number to cast?

 
Answer #9    Answered By: Burkett Bernard     Answered On: Feb 03

This web page has some good info. about casting it may interest u.<br><br>java.sun.com/.../conversions.do\
c.html#2752
9

 
Didn't find what you were looking for? Find more on how do u compile a prog? Or get search suggestion and latest updates.




Tagged: