[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Adding a Jar file to a project in Netbeans 3.6

Posted on 2004-10-21
8
Medium Priority
?
395 Views
Last Modified: 2012-05-05
How do I add a Jar file to a project in Netbeans 3.6? I've tried mounting the Jar file in the Filesystem. It appears in the Filesystem window where I can browse all of the different classes. Then I get an error on this line:

 public class MySensor extends SenBg.com.cole.Sensor{

The name of the Jar file is SenBg.jar.The error reads "package SenBg.com.cole does not exist".

I've tried adding this line just above it:
 import SenBG.*;

That doesn't work either, I get the same error. I've even tried copying the Jar file to the \lib\ext directory with no luck. However I'd rather find a solution that doesn't involve any file copying.
0
Comment
Question by:Nailhead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12373963
That should be more like

import com.cole.SenBg.*;

i'd guess.

Please list the jar in its directory by doing the following

jar tvf SenBg.jar

at the command line
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12373983
And i'd take a guess that should be

public class MySensor extends com.cole.SenBg.Sensor {}

but please list the jar
0
 
LVL 37

Accepted Solution

by:
zzynx earned 2000 total points
ID: 12374094
You add a jar file to the project by mounting it. That's correct.
But the classes inside that jar have a path too.   (You can open a jar with WinZip to have a look)
If you want to use the class TheClass and it is in the path x/Y/z in the jar file

then in your code you have to

            import x.Y.z.*;

that way you can use the class:

public MyClass extends TheClass {

}
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Nailhead
ID: 12374248
CEHJ, I tried your suggestions, without any luck. I listed the jar on the command line and here is one line from the class that I want to implement:

   646 Fri Oct 01 14:08:28 CDT 2004 com/cole/sensor/Sensor.class

I also opened it in WinZip and saw that the path is the same as the listing. Next I changed the line using zzynx's x/Y/z rule and it worked!

import com.cole.sensor.*;

That was the answer, thanks all!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12374325
I fail to see how (apart from mentioning WinZip) the accepted answer differs from the ones i already gave. If you'd posted that path as i asked you too, we could have saved a lot of time
0
 

Author Comment

by:Nailhead
ID: 12374562
CEHJ, The one most important difference in the accepted answer is that the Jar file is not cited in the code anywhere.

In your example, you cite the name of the Jar (SenBg):
import com.cole.SenBg.*;

The exact path of the Jar file that I'm implementing isn't relevant. What I needed to know was the general syntax, and that is what zzynx supplied.

I do appreciate your help.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12374609
>>The exact path of the Jar file that I'm implementing isn't relevant

It's the path *inside* the jar that is important, indeed the only thing that's important, which is why i asked you to list it.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12378291
Thanks for accepting
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question