ru/topjava/startjava/lesson1/
ru.topjava.startjava.lesson1
package ru.topjava.startjava.lesson1;
> tree /F
src
└──ru
└──topjava
└───startjava
└──lesson1
MyFirstApp.java
package ru.topjava.startjava.lesson1;
public class MyFirstApp {
public static void main(String[] args) {
System.out.println("Я познаю Java!");
System.out.println("Я программист.");
}
}
> where /R C:\ src.zip
C:\Program Files\BellSoft\LibericaJDK-20\lib\src.zip
C:\Program Files\JetBrains\IntelliJ IDEA 2022.3\lib\ant\src.zip
org.springframework.beans.factory
org.springframework.context
src/main/java/org/springframework/
src/main/kotlin/org/springframework
src/test/java/org/springframework/
src/test/kotlin/org/springframework/
ru.topjava.basejava.exception
ru.topjava.basejava.sql
ru.topjava.basejava.storage.serializer
package ru.topjava.example;
class SomeClass {
void method() {
...
}
}
hyphenated-name.example.org → org.example.hyphenated_name
example.int → int_.example
123name.example.com → com.example._123name
java.io
jakarta.enterprise.lang.model
org.hibernate.action.internal
com.apple.quicktime.v3
org.springframework.kafka.aot
org.hibernate.beanvalidation
gov.whitehouse.socks.mousefinder
import java.util.Scanner;
java.util.Scanner console = new java.util.Scanner(java.lang.System.in);
Scanner console = new Scanner(System.in);
import java.util.Arrays;
import org.springframework.beans.BeansException;
import ru.topjava.basejava.storage.ArrayStorage;
import static java.lang.Math.max;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static ru.topjava.basejava.storage.DataStreamSerializer;
import java.util.*;
import jakarta.annotation.*;
import org.springframework.beans.factory.config.*
package ru.topjava.startjava.lesson1;
import java.lang.*;
import ru.topjava.startjava.lesson1.*;
public class MyFirstApp {
public static void main(String[] args) {
System.out.println("Я познаю Java!");
System.out.println("Я программист");
}
}
> md out & ls -a
./ ../ .git/ .gitignore out/ src/
javac [options] [source-files]
> javac -d out/ src/ru/topjava/startjava/lesson1/*.java
> javac -d out/ src/ru/topjava/startjava/lesson1/MyFirstApp.java
package ru.topjava.clinic.animal;
public class Dog {
private String name;
public Dog(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void bark() {
System.out.println("Bark! Bark! Bark!");
}
}
package ru.topjava.clinic.person;
import ru.topjava.clinic.animal.Dog;
public class Owner {
private String name;
private Dog dog;
public Owner(String name, Dog dog) {
this.name = name;
this.dog = dog;
}
public String toString() {
return name + " и " + dog.getName();
}
}
package ru.topjava.clinic;
import ru.topjava.clinic.animal.Dog;
import ru.topjava.clinic.person.Owner;
public class Main {
public static void main(String[] args) {
Dog dog = new Dog("Spike");
Owner owner = new Owner("John", dog);
System.out.println("Меня и мою собаку зовут " + owner);
System.out.println("Голос, " + dog.getName());
dog.bark();
}
}
> tree /F src
src
└───ru
└───topjava
└───clinic
│ Main.java
│
├───animal
│ Dog.java
│
└───person
Owner.java
javac -d out/ src/ru/topjava/clinic/animal/Dog.java src/ru/topjava/clinic/person/Owner.java src/ru/topjava/clinic/Main.java
javac -d out/ -sourcepath src/ src/ru/topjava/clinic/Main.java
java [options] [mainclass]
> java -cp out/ ru.topjava.startjava.lesson1.MyFirstApp
Я познаю Java!
Я программист.
java -cp out/ ru.topjava.clinic.Main
Меня и мою собаку зовут John и Spike
Голос, Spike
Bark! Bark! Bark!
javac -d out/ -sourcepath src/ src/ru/topjava/clinic/Main.java
java -cp out/ ru.topjava.clinic.Main
java src\ru\topjava\clinic\Main.java
Меня и мою собаку зовут John и Spike
Голос, Spike
Bark! Bark! Bark!
> javac @argfile
-d ..\..\..\..\out
Dog.java
Person.java
Main.java
-d D:\Java\StartJava\out
Dog.java
Person.java
Main.java
> javac @options
> javac @options *.java
> javac '@options'
find ./src/ -type f -name "*.java" > sources
> cat sources
./src/ru/topjava/clinic/Dog.java
./src/ru/topjava/clinic/Main.java
./src/ru/topjava/clinic/Person.java
dir src /S /B *.java > sources
javac @options @sources
> shopt globstar
globstar off
> shopt -s globstar
> shopt -u globstar
> javac -d out/ src/**/*.java
> javac -d out/ -sourcepath src/ src/**/*.java
> find ./src/ -type f -name "*.java" -exec javac -d ./out/ '{}' +
> java @argfile
-cp ..\..\..\..\out
ru.topjava.clinic.Main
-cp D:\Java\StartJava\out
ru.topjava.clinic.Main
> java @optionsj
ru.topjava.abc
ru.topjava.def
ru.topjava.ghi
package ru.topjava.abc;
import ru.topjava.def.Message;
import ru.topjava.ghi.Message;
public class Main {
public static void main(String[] args) {
Message msg1 = new Message();
msg1.print();
Message msg2 = new Message();
msg2.print();
}
}
package ru.topjava.def;
public class Message {
public void print() {
System.out.println("def.Message");
}
}
package ru.topjava.ghi;
public class Message {
public void print() {
System.out.println("ghi.Message");
}
}
> javac -d out/ src/ru/topjava/**/*.java
> javac -d out/ -sourcepath src/ru/topjava/ src/ru/topjava/abc/Main.java
src\ru\topjava\abc\Main.java:4: error: a type with the same simple name is already defined by the single-type-import of Message
import ru.topjava.ghi.Message;
^
src\ru\topjava\abc\Main.java:9: error: reference to Message is ambiguous
Message msg1 = new Message();
^
both class ru.topjava.def.Message in ru.topjava.def and class ru.topjava.ghi.Message in ru.topjava.ghi match
src\ru\topjava\abc\Main.java:9: error: reference to Message is ambiguous
Message msg1 = new Message();
^
both class ru.topjava.def.Message in ru.topjava.def and class ru.topjava.ghi.Message in ru.topjava.ghi match
src\ru\topjava\abc\Main.java:12: error: reference to Message is ambiguous
Message msg2 = new Message();
^
both class ru.topjava.def.Message in ru.topjava.def and class ru.topjava.ghi.Message in ru.topjava.ghi match
src\ru\topjava\abc\Main.java:12: error: reference to Message is ambiguous
Message msg2 = new Message();
^
both class ru.topjava.def.Message in ru.topjava.def and class ru.topjava.ghi.Message in ru.topjava.ghi match
5 errors
package ru.topjava.abc;
public class Main {
public static void main(String[] args) {
ru.topjava.def.Message msg1 = new ru.topjava.def.Message();
msg1.print();
ru.topjava.ghi.Message msg2 = new ru.topjava.ghi.Message();
msg2.print();
}
}
> javac -d out/ src/ru/topjava/**/*.java
> java -cp out/ ru.topjava.abc.Main
def.Message
ghi.Message