DEV Community

Discussion on: Can I import local class files in Java, like you can Python?

Collapse
zoedreams profile image
☮️✝️☪️🕉☸️✡️☯️ • Edited

no, i would suggest reading this book deitel.com/java-how-to-program-11-...

you need to declare your package and make sure your including stuff from that.. stuff in java runs within a virtual machine and requires their own unique paths refered to classpaths which you specify when starting the jvm .. java cli

Collapse
baenencalin profile image
Calin Baenen Author

Question, if I have a package called runtdeale.code in the folder RuntDeale/resources/code, could I do import runtdeale.code.libs.org.json.*; to import the JSON library, which is a package below my original package?

Filesystem:

RuntDeale:
    resources:
        textures: ...
        ...
        code:
            Main.java
            manifest.txt
            ...
            libs:
                org:
                    json:
                        /* org.json library files */
Enter fullscreen mode Exit fullscreen mode