answersLogoWhite

0

What is java c?

User Avatar

Wiki User

13y ago

Best Answer

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)

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is java c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the features in java that makes it similar to C programming?

Java is not similar to C. Java is, however, similar to C++. Both C++ and Java are object orientated programming languages (OOPL's).


Major difference between c and java?

Java is object oriented, C is not...


Header files in Java programming?

Java does not require header files like C/C++.


Advantages of C over C plus plus and java?

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.


What are the feature of java which have been implemented in c?

None, as C was made prior to Java.


Which is easier 'C plus plus' or 'Java'?

Java is considerably easier than C++.


Where can you find Java and c compilers?

Java: At java.sun.com in the download JDKcategory.C: Google for "Free C/C++ Compilers"


Is it necessary for you to learn c and c plus plus before you go for java?

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.


Why you learn java language?

java language moreover solve the problems witch is encounter in c and c++ that s why we use the java language...


Which is more popular c plus plus or java?

Java


What is feature that supported in c c plus plus and java but not in net?

C, C++ and Java are cross-platform languages. NET is for Windows-only.


Why do you require a object in java but not in C?

Because Java is an object-oriented language and C is a procedural language.