#Compiling multiple files from a single file

26 messages · Page 1 of 1 (latest)

native sedge
#

I have a file called Test.java which uses Product class from Product.java so can I just run javac Test.java and somehow make the compiler compile the Prodcut.java file too? both files are in the same directory.

low hatchBOT
#

<@&987246399047479336> please have a look, thanks.

spring gyro
#

you do not have to compile first with javac, you can just do java Test.java and java will compile all files using javac for you and then run it

native sedge
#

is there any term for this method?

spring gyro
#

?

#

but also if you want to compile manually first without running it, javac detects all used files and compiles them too. but you do not need to run javac first, just use java

native sedge
#

I mean is this just called compiling or is there any other term for this... maybe I am overthinking?

spring gyro
#

java does compile it for you using javac and then runs the program, and since you usually want to run it there is no need to call javac manually

#

java does both steps at once

#

it has no term

#

you can call it compile and run

native sedge
#

Okay, thank you ❤️

low hatchBOT
#

Closed the thread.

spring gyro
#

but what you can not do is importing from the default package

#

when you import something the classes you are importing have to be inside of a named package

native sedge
spring gyro
#

i did not say anything about same package

#

i said classes you import have to be inside of a named package

#

you can import from different packages

#

but they can not be in the default package

#

default package is when there is no

package org.yourpackage.name;

at the top. when you have a package statement at the top it is inside of a named package, if not it is the default package

#

(it also has to be inside of according directories, every name seperated by a dot is a folder)

native sedge
spring gyro
#

correct

native sedge
#

ok makes sense, I was using reflectors and wondered how it was working without named packages... apparently its possible with reflectors.

#

ig I have to get my basics really strong peepo_java