how do I compile and run a java program?
JavaBean 0 Newbie Poster
Recommended Answers
Jump to Postto 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 …
Jump to Postopen 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 ENTERIf you used an IDE like …
Jump to PostI 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 ENTERThat might work, but your JDK needs to be set up correctly, the command prompt needs to know …
Jump to Postgrii_19 do not use this approach, this is considered bad practice to save anything into Java instalation folder. Please follow the link to the tutorial which I gave it to you in another post
Jump to PostOh man, the deaf leading the blind.
I have no idea where this "save it to the bin folder" stuff got started, but here ye, what rubbish.
I know, I know, now you're going to come back with, but it works and its better than nothing, so whats …
All 24 Replies
big_k105 11 PFO Founder Team Colleague
rickste_r 0 Newbie Poster
Barbank 0 Newbie Poster
cms271828 2 Junior Poster
Barbank 0 Newbie Poster
cms271828 2 Junior Poster
Barbank 0 Newbie Poster
JaksLax 0 Newbie Poster
Barbank 0 Newbie Poster
jaden403 0 Newbie Poster
Barbank 0 Newbie Poster
fastmike 0 Newbie Poster
grii_19 0 Light Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
grii_19 0 Light Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
lordkwena 0 Newbie Poster
malcah@cox.net -2 Newbie Poster
jwenting commented: zombie master -2
FlamingClaw 98 Posting Pro
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
jwenting 1,889 duckman Team Colleague
beefrocks 0 Newbie Poster
stultuske 1,116 Posting Maven Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.