Compile Java

Reply

Join Date: Jul 2004
Posts: 1
Reputation: JavaBean is an unknown quantity at this point 
Solved Threads: 0
JavaBean JavaBean is offline Offline
Newbie Poster

Compile Java

 
0
  #1
Jul 27th, 2004
how do I compile and run a java program?
Reply With Quote Quick reply to this message  
Join Date: May 2003
Posts: 307
Reputation: big_k105 is an unknown quantity at this point 
Solved Threads: 2
Team Colleague
big_k105's Avatar
big_k105 big_k105 is offline Offline
PFO Founder

Re: Compile Java

 
0
  #2
Jul 27th, 2004
to compile i believe you would run javac file.java and it should compile and to run it you would just use java file.class
and that should do it i believe you will have to locate these 2 files on your system javac and java i but not sure. this is of course if you are just running a command line program and not an applet
http://www.iam.ubc.ca/guides/javatut....1/stepbystep/

i have always just used text pad to do all my java stuff in cause you can set it up to compile and run your program
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 16
Reputation: rickste_r is an unknown quantity at this point 
Solved Threads: 0
rickste_r's Avatar
rickste_r rickste_r is offline Offline
Newbie Poster

Re: Compile Java

 
0
  #3
Jul 28th, 2004
This link may help you to understand how to compile and run java programs.
The only thing is I cant find which windows operating system its for, probably windows 98, 2000. However it can be easily adapted to windows xp!

LINK
Only lemmings should jump to conclusions! :rolleyes: Please rate me!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 5
Reputation: Barbank is an unknown quantity at this point 
Solved Threads: 0
Barbank Barbank is offline Offline
Newbie Poster

Re: Compile Java

 
0
  #4
Oct 20th, 2006
Ok, so I found two lcations of this javac and every time i click on either one of them a window flashes by and disappears? How the heck are you supposed to run javac? How do you compile? The link doesn't help. It assumes you know how to compile. Sorry, I'm new to Java and I just wanna learn how to compile.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 101
Reputation: cms271828 is an unknown quantity at this point 
Solved Threads: 4
cms271828 cms271828 is offline Offline
Junior Poster

Re: Compile Java

 
0
  #5
Oct 20th, 2006
open your command prompt.
Change your directory to wherever your programs are...
Eg if they are in C:\java, then:
cd c:\java ENTER
Then javac fileName.java ENTER
That line compiles it, and creates a .class file,
Next... to execute the program...
java fileName.java ENTER

If you used an IDE like netbeans 5.0 or something else, you don't have to bother with this, but they can be confusing to start with, so I recommend just playing with notepad and command prompt till you get the hang of basic java.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 5
Reputation: Barbank is an unknown quantity at this point 
Solved Threads: 0
Barbank Barbank is offline Offline
Newbie Poster

Re: Compile Java

 
0
  #6
Oct 20th, 2006
OK, I got as far as getting into the C:\java folder, but there is no javac found so it stops there. I'm sorry. I'm a total newb here.

I ran the code javac MyFirstApp.java ENTER like you said, and I get an error saying it's not a command. HELP!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 101
Reputation: cms271828 is an unknown quantity at this point 
Solved Threads: 4
cms271828 cms271828 is offline Offline
Junior Poster

Re: Compile Java

 
0
  #7
Oct 20th, 2006
I made a little error above,,,
you just need to do java fileName to execute.

Ok, try this...
cd c:\java ENTER
SET CLASSPATH= ENTER
javac fileName.java ENTER
java fileName ENTER

That might work, but your JDK needs to be set up correctly, the command prompt needs to know the path to the JDK, you can do this by modifying the AUTOEXEC.BAT file.
Let me know how it goes with the commands I mentioned first.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 5
Reputation: Barbank is an unknown quantity at this point 
Solved Threads: 0
Barbank Barbank is offline Offline
Newbie Poster

Re: Compile Java

 
0
  #8
Oct 20th, 2006
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Compaq_Administrator>cd C:\java

C:\java>SET CLASSPATH=

C:\java>javac HelloWorldApp.java
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\java>java HelloWorldApp.java
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp/java

C:\java>java HelloWorldApp
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp

Still nothing. The official javasun site had a different way of resetting the path though. I don't understand either way...heh
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 21
Reputation: JaksLax is an unknown quantity at this point 
Solved Threads: 0
JaksLax's Avatar
JaksLax JaksLax is offline Offline
Newbie Poster

Re: Compile Java

 
0
  #9
Oct 20th, 2006
Post the code your trying to compile, the last couple lines in your last post look to be issues with your code
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 5
Reputation: Barbank is an unknown quantity at this point 
Solved Threads: 0
Barbank Barbank is offline Offline
Newbie Poster

Re: Compile Java

 
0
  #10
Oct 20th, 2006
  1. /**
  2.  * The HelloWorldApp class implements an application that
  3.  * simply prints "Hello World!" to standard output.
  4.  */
  5. class HelloWorldApp {
  6. public static void main(String[] args) {
  7. System.out.println("Hello World!"); // Display the string.
  8. }
  9. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC