-1

So I have a folder structure as below

mainFolder\
    bin\
        file1.class,file2.class,file3.class,file4.class //under package named classes
    src\
        socialmedia\
            file5.java,file6.java,file7.java //under package named socialmedia
        PlatformTestApp

How can I import the package inside the bin folder from the socialmedia subfolder inside the src folder

I'm aware a question like this has almost certainly been answered before but I can't for the life for me find what I need

Samuel W
  • 39
  • 7
  • Are you trying to use code from compiled java code? A bin folder should have .class files and not .java files – Nexevis Mar 16 '23 at 18:47
  • @Nexevis yes sorry forgot to specify file types, updated the post now – Samuel W Mar 16 '23 at 19:59
  • Where is file1.java, file2.java? If the answer is that they are in another project then you need to make a jar from that project, add the jar to this project (usually in lib) and add the jar to the classpath. Or you could use maven/gradle dependencies. – John Williams Mar 17 '23 at 13:03
  • @JohnWilliams file1.java etc. don't exist, that's just how I named the files. So how can I access the class files from within file6.java in the socialmedia package – Samuel W Mar 17 '23 at 14:31

1 Answers1

1

Any files on the classpath, which /bin certainly is, can be accessed like this:

InputStream in = this.getClass().getClassLoader()
                                .getResourceAsStream("file1.class");

I have to ask - what problem are you solving that includes this very unusual requirement?

John Williams
  • 4,252
  • 2
  • 9
  • 18