answersLogoWhite

0


Best Answer

You are supposed to use the same name for the filename and the class name. I am not entirely sure what happens otherwise; at the very least, I would expect that you would get unnecessary complications.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you compile and run with the same file name provided file name and class name are different?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you compile and run with the file name provided file name and class name are different?

That would depend on the language and development system you are using, which you did not identify.


What is the command to compile a java program named Greetingsjava?

The command to compile a Java program is "javac", followed by the class name (file name).


How do you make a java class?

You write the source code, in a text editor, or better in a special IDE. The source code should have the extension ".java". You can have several classes in the same file. Then you compile the class to bytecode; this creates a file with extension ".class".


How do you compile servlet in java using tomcat?

Tomcat is a server. It is used to deploy and run Servlets and not compile them. A Servlet is a java file and has to be compiled just like any other Java Class.


Will the java compiler translate a source file that contains syntax errors?

No it will not. Any java source file that has syntax errors will not be translated fully. The compiler will spit out errors based on the syntax problems in your code.


Why the name of a java file is same as the name of the public class?

It is not compulsory that the java file name and name of the public class should be same. if u will give java file name and public class name different then u have to compile and run the program with another names. for example: u have named class sample i.e. (public class sample) and main function is also defined in this class. and u have saved the file as abc.java then u will first comple the file as: javac abc.java now run the file (type java class name(in which main function is defined) i.e. java sample try it.


How do you compile php code?

If you are looking to create an executable (.exe) file on windows then I highly recommend this program to compile your php source code to an exe file.


How do you compile a java program when it is in another directory?

using javac command and mentioning fully classified class name. Fully classified here means class name along with the package hierarchy in which the class is stored in .java file


Does Java compile too - machine code or an intermediary exe?

Java files can be compiled. The output is a machine understandable file that has a .class extension which can be executed by the JVM


Can you compile program without header file?

Yes,we can compile our program without header file without any error,but we can not use any predefine functions like printf,scanf.


How can you compile the jsp file?

JSP file would be automatically compiled by an engine called Jasper in the servelt containter.


The name of a Java program file must match the name of the class with the extension java?

not exactly..... only If your class is public then the java program name should be the public class name with extension Sample.java >> public class Sample { public static void main(String[] args) { ..... } } NonPublicClass.java class SomeOtherName { ......... }