I m working in a project A (java)in IntelliJ IDEA , now I need functionality from another project B(java) .I want to import desired packages from project B into Project A. How can I achieve it?
I would recommend you use a build system like Gradle or Maven. That way, anyone who is able to check out your projects from version control will be able to build your projects, even if they choose not to use IntelliJ. (While either Gradle or Maven would work, I do not recommend using the Ant build system, because it does not support dependencies out of the box.)
You can either create a multi-module Gradle build, which is the easiest, or you can even publish a jar to a repository like Artifactory and then depend on a particular version of that jar in your second module.