Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » JAR File Import Problem(JAR File)
JAR File Import Problem [message #1827759] Fri, 22 May 2020 11:04 Go to next message
Eclipse UserFriend
Hi guys, I followed the instruction of this video on how to export and import JAR file. It doesn't seem to work.

Look up "What is Jar file? | How to make a Jar in Eclipse?" by Telusko on Youtube.

So I exported Simple_Program folder, which contains CalDemo.java, the code is:

package Cal;

public class CalDemo {

public int add(int i, int j) {
return i + j;
}

}

Then, I exported the project folder Simple_Program as Calculator.jar (JAR file). Then I created Simple_Program2, inside project folder, I cretead class CalDemo2.java.

package Cal2;

import Cal.CalDemo;

public class CalDemo2 {

public static void main(String[] args) {

CalDemo c = new CalDemo();

System.out.println(c.add(4, 8));

}

}

Then, I imported Calculator.jar via "Add External JAR Files" into Simple_Program's Referenced Library. CalDemo.class appears in the .jar file branch instead of CalDemo.jar. Then, when I click on CalDemo.class, it says Source Not Found. So, when I run CalDemo2.java, I am getting an error. Error message attached in image below.

Also, I tried to assigned path to CalDemo.class and it's not working either. Now, I cannot re-assign path to that file.
  • Attachment: z.bmp
    (Size: 5.15MB, Downloaded 76 times)
Re: JAR File Import Problem [message #1827765 is a reply to message #1827759] Fri, 22 May 2020 15:35 Go to previous message
Eclipse UserFriend
Quote:
... when I click on CalDemo.class, it says Source Not Found


That shouldn't surprise. Normally, jars don't contain sources. You could either explicitly include sources in the jar, or provide a source attachment, but neither is required for running.

Concerning the runtime error I suggest to open the Run configuration and visit the Dependencies tab. Does it show your jar file on the classpath? You may also click "Show Command Line" to see exactly how the application is run.
Previous Topic:Boxing of call arguments
Next Topic:Error at update
Goto Forum:
  


Current Time: Fri Jul 25 01:28:59 EDT 2025

Powered by FUDForum. Page generated in 0.03816 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top