Reputation: 1178
I have two folders:
Network/
+ Network.java
Router/
+ Router.java
Is there any way in java to import Network.java into Router/ folder? Or I can only copy it directly into a folder for this to work?
Upvotes: 0
Views: 828
Reputation: 323
IDE: If you're using an IDE like Netbeans oder Eclipse, you can just drag and drop the file to the package required. After this action the IDE will perform some refactoring and that's it. For more details refer to the posting above.
Upvotes: 0
Reputation: 59096
You can import things from nearby folders using packages.
For instance, if you have this file structure (in which I have changed the names of the folders to lower case):
network/Network.java
router/Router.java
And you have
package network;
at the top of Network.java
, and
package router;
at the top of Router.java
, then you can import Network
into Router.java
using:
import network.Network;
This assumes that you are trying to import a public class, declared inside Network.java
as:
public class Network {
...
Upvotes: 1