Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file naming conventions

Status
Not open for further replies.

venkman

Programmer
Oct 9, 2001
467
0
0
US
According to the specification of java, does a file have to be named "<public class name>.java" ? I know that the sun compiler I use on my linux box throws an error if you try to compile a file like "foo.java" with a public class of "bar" in it, but is this just a recommendation that sun's compiler follows, or is it an actual requirement for every java compiler?

-Venkman
 
As far as I know it is universal. More importantly it is good practice.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
a file named "foo.java" must have a "public class foo" in it.
 
hmmm... does have anyone have a place where I can cite this in the specification for java compilers. I know I've seen it in every compiler I've ever looked at, but I'm in the midst of an academic argument about it and need an official source to reference to.
 
According to this page, the naming convention is not required by the Java Language Specification, but it is a policy enforced through the JDK. I happen to think it is a good policy to have.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
A quick scan through the JLS, I cannot see anything enforcing this naming convention in non-Sun compilers, however if you really want the definitive answer, I would read the JLS yourself :


--------------------------------------------------
Free Database Connection Pooling Software
 
Good practice is of couse 'Foo' in 'Foo.java' - not 'foo'.

I don't know, if every compiler compiles from Files - I could imagine saving sources in Databases, or getting them fileless from some generator... but don't know of any.

And I guess the compilers depend on this rule, to find the sources quickly.

But I don't have a official link too.

seeking a job as java-programmer in Berlin:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top