views:

130

answers:

4

How can I compile and run a Java program?

+6  A: 

http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html#win32-2b

Is English difficult for you? There are tutorials for your language too.

Gunslinger47
+2  A: 

to compile:

javac path/to/file/with/main.java

then to run:

java path/to/file/with/main

Robert
Um, no. java takes a class name in foo.bar.baz.ClassName syntax, not a pathname of a .class file.
bmargulies
both work for me
Robert
A: 

I would suggest that if you are starting with the java language, first use an IDE (Eclipse, Netbeans, Intellij IDEA or another. For a first step let the IDE do his job. Then once you evolve quickly use a build manager (Ant, Maven, Gradle, ...). It is a good practice to always have a build manager in place to keep the build in control.

Matthieu BROUILLARD
A: 

This is super common knowledge. This is not a problem.

  1. Use Google and search for special words "java compile tutorial"

  2. Java is created by Sun, so it's logical to check their tutorials and examples - they are good!

  3. What is your environment setup? What have you tried and not succeeded? You haven't provided that info.

  4. Use special tools IDE - good example is Eclipse and NetBeans. They will help you compile - special button.

  5. command using console:

    javac <path-to-java-file> If you need special help use javac -help

Leni Kirilov