English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i tried running my little program after javacing both java files but it doesnt run - the class file is stored in the same folder - but i think it needs to go somewhere else.

hope someone can help.

2007-08-31 08:00:30 · 3 answers · asked by Julie C (little ninja) 1 in Computers & Internet Programming & Design

3 answers

If you used the default package (i.e., did not specify a package), then you just need to add that directory to your classpath.

So, if you used:

javac foo.java

.... to compile the program from the directory containing your java file, then you'd use:

java -cp . foo

... to execute it. Adding "." (current directory) to the class path ("-cp") will enable your class to be seen.

2007-08-31 10:13:43 · answer #1 · answered by McFate 7 · 1 0

steps to run java prog.
1)Write your program on notepad and save it aslike
yourprog.java
2)Compile your program
on command prompt
c:/>javac path of yourprog.java

3)once compiled you can interpretate(run) it with
C:/>java path of your classfile.
note:: classfile might be different then your prog file
its the class which has main method.
there you go!!

still having problem
check whether you have set correct classpath or not.

hope this helps
Cheers:)

2007-08-31 09:40:21 · answer #2 · answered by Neeraj Yadav♥ 6 · 1 0

Hi,

You just can run a class file with the java executable from your java directory; for example: c:\your-java-dir\bin\java.exe YourClassFile; stated that you have a public static void main(String args[]) method. This method is being called when you just run your class-file.

Good luck!

2007-08-31 08:22:07 · answer #3 · answered by Pacstah 1 · 1 0

fedest.com, questions and answers