简体   繁体   中英

How to generate package structure from standalone *.java source files?

I've been searching for answer for my problem but I can't find some relevant information, so I'm asking. I've directory which contains thousands of Java classes with source code (*.java files). Each of those files contains information to what package the file belongs, its classnames + code itself of course. I need to find some function of the Eclipse IDE (or maybe of another IDE) which is able to reconstruct packages under the 'src' directory based on the information in the class files and bring to me a good Java project structure so the restored packages and its classes can be easily imported into a new Java project then. Creating the structure of packages manually would take me (maybe) lot of days...

For clarification:

I have: directory which contains: 1.java, 2.java, 3. java, n.java...

I need: directory which will contain:

[src] -> [package_1] -> [1.java, 2.java, etc...] ... [src] -> [package_m] -> [3.java, n.java]

I think this must be possible somehow as the each class file contains information to which package it belongs actually.

Just if you find no better solution: At least you can import all sources into a project in Eclipse and have Eclipse move each file to the right package by means of using the quick fix for each problem . You still need to press 3 keys per wrong package declaration, but it saves you from fiddling with files and folders.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM