S
S
still_452021-02-20 19:59:22
Java
still_45, 2021-02-20 19:59:22

Running a file as a class from a folder?

Good day, the essence of the question is this: there is a program inside which a cycle that scans the folder for new files (classes), if a new class is found in the folder, an instance of this class is created and executed (they are talking about adding a class already at the time the program is running ) . so how to launch such a class inside the program if its name is unknown? as if it is clear how to get the name of the class, etc., but create an instance of it and execute xs. Don’t scold too much if the question is childish, I’m just learning, I honestly googled on this topic - I didn’t find any information

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2021-02-20
@still_45

Googled pretty well how to do it
An example of class loading is described for example here https://stackoverflow.com/a/6219855
And then, skipping the first line, since the class has already been received, call one of its constructors https://stackoverflow.com/a /9886331

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question