Traditionally, where do you store Java Class file?
I have a Java SRC folder where I store my Java file Then I use terminal to compile them and finally get them in the same directory Class file It doesn't necessarily bother me, but I've never seen it professional
By professional convention (if any), in which folder in the project directory should the compiled be stored Class file?
Solution
If you are not familiar with it, you should study the topic of Java classpath I remember finding this confusing when I first started programming in Java
There are in Java Class file definition search path; When you run Java - CP blahblahblah that sets the classpath java -jar blahblahblah. Jar open a jar file The manifest of the jar file can indicate the classpath The default classpath is in the current directory
Typically, you place Java classes in packages in a hierarchical directory structure in the file system, in which case the java compiler will also The class file is placed in the corresponding structure
If you run javac from the command line, - D argument specifies The target root directory of the class file
A typical project looks like this. Suppose your package name is com example. Foo, which contains foo Java and bar java:
project_dir/ src/ com/ example/ foo/ Foo.java Bar.java bin/ com/ example foo/ Foo.class Bar.class
The java compiler will execute using - D bin as the target directory, which will create and Java file Class file But the destination does not have to be called bin; If you like, you can call it Freddy or dumbass, although it may get people used to dustbins or construction
In most cases, when a java program or library is built The class file is just a build Jar file is a temporary step (basically just a. ZIP format with. JIP extension, including. Class file and some metadata). When you actually run them, if you include it in the classpath, Java will use Jar file