answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

For Windows and Dos:

1. Install the Java Development Kit (JDK) fromthe Java or Oracle web site into C:\ drive.

2. Set path by giving following command path = %path%;c:\jdk1.3\bin;c:\jdk1.3\lib with your proper version of JDK(i.e. jdk1.2.2 or jdk1.2 etc).

3. Write simple program in Edit of Dos or Notepad with "class_name.java". Here class_name is the name of file you used in your program with the keyword class. Remember that Java is case sensitive.

4. Compile the program with the command "javac class_name.java". If there are compile errors, fix the source and repeat this step again until it works.

5. Run this command "java class_name". If the program does not work correctly , review the code, fix the errors and repeat step 4 above.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

When you install Java, you get the Java compiler: javac.

To compile a Java source file you can run:

javac MyClass.java

On Terminal Mac I write:

cd Desktop

javac myClass.java

cd = change directory followed by the directory of the java file (I have chosen the Desktop) push enter.

write javac (Java Compile) followed by the java files name and extension and push enter (this will create a .class file to the Desktop).

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

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.

Running Java Programs

The java command is used to invoke the Java virtual machine. This command invokes the JVM and asks it to run the program that is specified in the argument.

java [options] className [args]

The [options] and [args] parts of the java command are optional, and they can both have multiple values. You must specify exactly one class file to execute, and the java command automatically assumes that you're going to send only a .class file, so you don't have to specify the .class extension on the command line. Here's an example:

java MyTestClass 1 2 3

The above command invokes the .class file of our test class MyTestClass and passes 1, 2 and 3 as command line arguments.

For fun, just assume that the hypothetical code inside MyTestClass expects 3 command line arguments. Don't worry, am not going to bore you with the code of that class here…

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

javac somefile.java

^that will compile

java somefile.java

^that will execute

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

javac programname.java

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you compiling a source code in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Extension file for Java?

Java source files have the .java extension, compiled Java class files have the .class extension.


What do you compile?

Compiling is the act of translating human-readable source code to machine-readable byte code.In Java, the compiler program is javac


What does java generate after compiling the java source code?

Java compiles to Java byte code; the native language of the Java virtual machine (JVM). The JVM is essentially just an interpreter for Java byte code. Each supported platform has its own JVM implementation so the same Java byte code can be executed upon any platform without further compilation, unlike C++ where source code must be compiled separately for each supported platform. However, interpretation results in slower execution speed and higher resource consumption than with C++ which compiles to native machine code.


What kind of file contain java source code?

'.java' files contain java source code. One can access these files on windows by using 'notepad'.


Where does source code come from in java?

Source code comes from the programmer...


What does the Java compiler translate Java source code to?

The Java compiler translates Java source code to Java byte code.


Java source code for median filter algorithm?

research is going on to develop a source code for median filtering using java


Differencitate between source code and bytcode in java?

The source code is just the set of statements written in (any included) java language by a programer (in this case our source code is a text file with .java extension). And in other hand a bytecode is the resulting code of compile a .java file, It is not machine code, but it can be interpreted and executed by the jvm.


What does a compiler perform?

A compiler converts high-level source code into native machine. In the case of Java, source code is compiled to Java byte code suitable for interpretation by the Java virtual machine which produces the machine code.


Where does bytecode come from java?

It is created by the Java compiler, based on the source code (the .java file).


How would you convert a folder full of class files to java files with the correct names for re-compiling?

I use JD-GUI to de-compile class files back into their java equivalents. This has saved me once or twice when I lost the source code on a project and I needed to update it.


How do you extract the java source code of a java based open source software?

If the software is open source then generally they will provide the code in a separate link. I don't think it is possible to reverse-engineer the code of a program.