0

I created a custom jar file for the purpose of learning how to build my own jar file. So, basically, it is a hello world jar. I followed the steps from this URL. The following is my program:

public class TEST_JAR {

    public static void main(String[] args){

    }
    public void helloWorld(){
        System.out.println("This the new JAR WORLD!!");
    }

}

This is the Manifest.txt file:

Manifest-Version: 1.0
Created-By: 1.8.0_111 (Oracle Corporation)
Main-Class: TEST_JAR

The JAR file is creating successfully. But when I use it in another application, the import statement is not showing the class file to import. I am using IntelliJ-IDEA.

Any clues on what is going wrong?

Community
  • 1
  • 1
AKA
  • 3,927
  • 4
  • 20
  • 35
  • 1
    how you use this jar in your application? – YCF_L Apr 17 '17 at 07:37
  • @YCF_LFile -> Project Structure -> Libraries -> + -> JAVA -> selecting 'myjar.jar' -> Apply -> OK – AKA Apr 17 '17 at 07:44
  • no i mean how you use your class `TEST_JAR ` ? – YCF_L Apr 17 '17 at 07:46
  • Ok. I was trying `import TEST_JAR`. – AKA Apr 17 '17 at 07:48
  • 1
    and where are the package name for example `import com.packagename.TEST_JAR;` ? – YCF_L Apr 17 '17 at 07:49
  • I didn't specify any package name. Is that necessary? – AKA Apr 17 '17 at 07:53
  • try to use a package @BBHeeMAA – YCF_L Apr 17 '17 at 07:57
  • note, that URL is useful to people who not use IDEA, you are using Intellij, so you can create your own jar there, no need to cmd and commands, just build your jar and you can use this jar in your projects, i'm not familiar with intelij i'm using netbeans i already create same project and run it in another project in less then 2 min – YCF_L Apr 17 '17 at 08:03
  • 1
    You can't import classes from the default package: http://stackoverflow.com/questions/283816/how-to-access-java-classes-in-the-default-package – CrazyCoder Apr 17 '17 at 10:05
  • @YCF_L CrazyCoder I tried using a package and it worked fine. Thanks. – AKA Apr 18 '17 at 04:20

0 Answers0