Compiling Java Programs
The javac command is used to invoke Java's compiler and compile a Java source file.
A typical invocation of the javac command would look like below:
javac [options] [source files]
Both the [options] and the [source files] are optional parts of the command, and both allow multiple entries. The following are both legal javac commands:
javac -help
javac ClassName.java OneMoreClassName.java
The first invocation doesn't compile any files, but prints a summary of valid options. The second invocation passes the compiler two .java files to compile (ClassName.java and OneMoreClassName.java). Whenever you specify multiple options and/or files they should be separated by spaces.
This command would create the .class files that would be require to run the java progam.
Compiling with -d
By default, the compiler puts a .class file in the same directory as the .java source file. This is fine for very small projects, but once you're working on a project of any size at all, you'll want to keep your .java files separated from your .class files. The -d option lets you tell the compiler in which directory to put the .class files it generates (d is for destination).
Lets take a look at two example commands:
javac -d classes source/MyTestClass.java
javac -d ../classes com/scjp/test/MyTestClass.java
Example 1 - Compile file named "MyTestClass.java" that is present inside the "source" sub-directory of the current directory and put the .class file in the "classes" sub-directory of the current directory
Example 2 - Compile the file named "MyTestClass.java" that is present in the following directory hierarchy "com/scjp/test/" from the current directory and put the .class file in the folder "classes" that is present one level above the current directory
One thing you must know about the -d option is that if the destination directory you specify doesn't exist, you'll get a compiler error. If, in the previous example, the classes directory did NOT exist, the compiler would say something like:
java:5: error while writing MyTestClass: classes/ MyTestClass.class (No such file or directory)
Java is not similar to C. Java is, however, similar to C++. Both C++ and Java are object orientated programming languages (OOPL's).
Java is object oriented, C is not...
Java does not require header files like C/C++.
C can be faster than C++ programs, and definitely faster than Java, since Java is primarily interpreted. C is also somewhat less rigid in definitions as well, not as tightly structured as either C++ or Java can be.
None, as C was made prior to Java.
Java is considerably easier than C++.
Java: At java.sun.com in the download JDKcategory.C: Google for "Free C/C++ Compilers"
No. You can learn Java first if you want. However, from a language perspective, C++ and Java are nearly identical1, and C is the predecessor of C++, so some people feel that the proper sequence is C, then C++, then Java. It is entirely up to you. ----------------------------------------------------------------------------- 1Nearly identical, that is, from a language perspective only. The environment and libraries are vastly different between C++ and Java.
java language moreover solve the problems witch is encounter in c and c++ that s why we use the java language...
Java
C, C++ and Java are cross-platform languages. NET is for Windows-only.
Because Java is an object-oriented language and C is a procedural language.