Question

I’m working with Net beans IDE and I want to add a piece of code to my project in a way that the source code won’t be visible to the user who is running the project, I decided to export that piece of code as a jar file in eclipse and then add that jar file to the project. But unfortunately net beans does not let me import that. It says which it is expecting a . Or when I insert. It goes in to that class and I cannot import that jar file into the project by import instruction. Is there a command in net beans which creates and object from jar file and then makes access to the functions and classes of the jar file? Would you please give the format of that instruction? If you know a better way to do this task I would be so happy if you share it with me

Was it helpful?

Solution

It's not that Netbeans doesn't let you import the classes but it cannot find the classes you want to import. You should first add the dependency jar file to your Netbeans classpath.

I assume that you are building an Ant project. For a downstream project, right click on the project in project browser then choose Properties menu from popup menu. Select Libraries node from the catagories box. You can now add jar file to your project using the add jar file button on the right.

However, I recommend you to have a look at building your project using maven. You can configure the dependencies using xml. Having said that, you should use whatever you are the most comfortable with.

P.S.

  1. It's "Netbeans", not "Net beans".
  2. You can build a jar file using Netbeans. You don't have to go all the way to Eclipse just to build a jar file.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top