how to create jar of java package in intelliJ idea - intellij-idea

I need to create a jar with compiled classes from a package which is inside of the module. I have a jar file which is actually a package inside of the module and I need to re-create it.
I can create jar of the whole module but I could not create the jar file of the package. How can I do that on idea?

Intellij IDEA 2016.3
File -> Project Structure...
Project Settings -> Artifact in the left column
"+" in the middle column -> JAR -> Empty -> Type name
Click the created Name in the middle column
Output Layout (right column) -> "+" (Add Copy of) -> Directory Content
If your .class file is in com.myprojects.myfirstproject you should create "com" folder in the root of jar, "myprojects" folder in the "com" folder, "myfirstproject" in the "myprojects" folder
"+" -> File -> select your .class files from com.myprojects.myfirstproject
Create Manifest File in the root of jar
Specify Main Class as "com.myprojects.myfirstproject.Main"
Apply
In the IDEA Top Menu: Build -> Build Artifacts... -> select your artifact -> Build.
You can find the created artifact in the Output directory specified on the step 3.

Related

Can I add an external directory (or file) to IntelliJ IDEA's project view?

I'd like to know if there is a way to add existing directories to the IntelliJ project view, e.g. (in my case) a config folder located outside the project.

IntelliJ Content root resets after closing Project

I have a simple project with 1 module in IntelliJ. I go to File -> Project Structure -> Module -> Add Content Root and set the root of the project folder to be the project root, but after I close the project, or quit IntelliJ and open the project again, the content root is not set.
IntelliJ Community v2020.2
MacOSX Big Sur 11.0.1
I fix it by:
quit IntelliJ
delete .idea file in the folder
open the project again

Include external files (not libraries) in a project in Intellij

I have a project ‘P’ in directory ‘P’. I want the use a css file in ‘P’ but the css file is not in directory ‘P’. It is at one level above ‘P’. Could I still include/use the css file in ‘P’ without changing the directory structure or making a copy of the css file?
Yes, you can add directories outside of the root project directory:
Project Structure → Modules → Sources → Add content root
Then after adding a directory, you can see it under your project root.

revert source root folder to plain folder

I created .clj script in the package com.lapots.game.journey.math. I saw notification that my clj file is not under source root.
At that time I did not know that I could make clojure folder as source root so I made my new package as source root.
However now I am unable to unbind math folder as source root and display it as package com.lapots.game.journey.math instead of just math. As result when I made an attempt to create clojure namespace with clojure kind
As a namespace in my clojure file inside math folder I've got just
(ns script)
instead of
(ns com.lapots.game.journey.math.script)
How to revert math folder from source root to a plain package?
Right click the directory in the project pane and select Mark directory as -> Unmark as sources root.
Simple answer:
Close IntelliJ
Delete the .idea directory & all contents
Re-start IntelliJ and select File -> New -> Project from existing sources
Navigate to your root directory and select project.clj and click OK.
I'm not sure about your namespace organization, but I assume you know it must match the directory hierarchy for both clojure and java.

intellij idea custom output directory

In Eclipse I am able to configure output folder for every directory in project. For example:
src/main/java -> app/target/classes
src/main/resources -> app/target/classes
src/main/custom_data -> app/custom_data
I cannot find out how to specify output directory for my 'custom_data' folder in IDEA. Is it possible?
You need to create a separate module which would have your custom_data directory as a source root or a resource root. Then you'll be able to specify the output directory for that module.