NetBeans importing classes package problems - class

I have created a class in Java that I need to import into NetBeans and use in a GUI. What I have done so far is add the jar file containing the classes to the library in my project. I can look inside the jar file and see the classes I need inside the . I have looked around online and know that the best to way import these classes is to move them to another package that isn't the .
My problem is that I do not know how to do this. I saw that I can create a package in netbeans, but it is gray when it appears and I can't seem to do anything with it. I basically have no idea how to create packages that I can use to import classes If someone could please walk me through step by step I would greatly appreciate it. I have looked at the other posts on this site and other places online, but they seem to skip over somethings I am not sure about. My teacher didn't mention anything about packages either, so I am really in the dark.

You can copy your source files (*.java) in your project's src folder, then use refactoring to change the package.
Right-click your java file, then select Refactor > Move and type your new package name.

Related

eclipse - folders for classes

I have a android app in eclipse, and by the time I have more and more classes in it.
As you can see, its pretty messy.
In visual studio I know how to add sub folders in the project, and organize the classes in a more ordered way (for example Interfaces folder, Client folder etc).
How can I do it in eclipse without messing with the namespaces or causing any errors? do I add packages?
thanks!
Yes, you need to create package inside of "com.example.tremp" by right-clicking it.
I think it should have a name including the parent package name (e.g. "com.example.tremp.activities"), but I have tried naming it without parent package name (e.g. "activities") and it worked fine by me.
I think the only way is to create new packages and then assign each class to a package .

How to show shortened project names in the Eclipse package explorer?

I work for a big company that has standards on Java project names. Long standards:
com.company.department.subdepartment.stream.project
Rather than let the package explorer take up a sizable portion of my screen, I'm looking for a way to shorten the project names. Mousing over project names shows the full name, but it's still very slow to determine which project I want to look at next with the incredibly long names. As has been answered before, package names can be shortened. I've got a rule set up, but it only works for packages:
com.company.department.subdepartment={department}
Is there a way to do an analogous thing for project names in Eclipse?
Package explorer uses the org.eclipse.jdt.internal.ui.packageview.PackageExplorerLabelProvider class to provide the view labels. Going through the source of this I don't see any support for shortening the project names.
The following ideas depend on how your eclipse workspaces are setup. If you're lucky and you just import project from your VCS, these could work for you.
If you're using maven, Eclipse project names are usually derived from your GAV. The Import as Maven project wizard has options for what pattern to use for the project name based on your maven GAV.
Otherwise, you can sometimes just right click the project -> rename. YMMV if you have any scripts or such that have the project name hardcoded. If you have these constraints, find those scripts and use variables rather than hardcoding.

Is the J2SE com.google.zxing.client.j2se.MatrixToImageWriter still the standard way to write barcodes?

I notice that there are a lot of old tutorials from about 2010 that use
com.google.zxing.client.j2se.MatrixToImageWriter
to write 2D barcodes to files.
Also, I notice a lot of old tutorials specify the use of Android.
I am using Eclipse on Linux Mint, not Android.
Eclipse will happily import the main src tree of java files and show them as available packages. For example, I can get all the packages under zxing/core/src/main/java to show up; I can import classes from those packages and compile them.
However, I can't seem to import the com.google.zxing.client.j2se package when I have the core packages imported, and vice versa.
If there is a way to write BitMatrix objects to files without using
com.google.zxing.client.j2se
that would simplify matters.
Alternatively, if there is some way to get Eclipse to import both sets of packages, that might be an alternative. I have already tried modifying the "filters" under the "properties" tab, on the theory that if I can use two filters, the first can pick up
core/src/main/java
and the second can pick up
/javase/src/main/java/
But that didn't work for me.
Suggestions are welcome. Thanks.
Ran into the same problem with the import. It appears that we both forgot to add the javase.jar into the project. Download it from here, import and you will be able to import MatrixToImageWriter.

Files filter plugin in eclipse (in Package Explorer - Navigator)

I want to create a some custom filters for my eclipse project. I think this can be done extending a plugin.
For example .asm file should go to the ASM filter, .c files to the C filter, and so on.
All my input files are stored in the Source folder (on my computer).
But I need this filters only for a better file management, in the Package Explorer.
Please, if anybody have a starting point for this issue ... I will appreciate.
The sooner, the better :)
You might want to have a look at this:
Eclipse Common Navigator Framework
And read this tutorial to create a custom navigation:
Custom Navigator
(It's part 7, but in the beginning there is a lot of theory. just find your personal starting point)
I hope this is what you were looking for or that you can at least get something useful out of it...

How to create .jar from specific package (without main) in Netbeans?

There are a lot of similar questions, but none for this specifically. I have a Netbeans project with a bunch of packages. Only one has Main. I'd like to be able to create a .jar from just one of the packages (and all the classes it contains, of course), which doesn't have main.
Is this feasible without having to put that package in another project or without having to screw around with build.xml? If the latter, any easy way or good rtfm links?
The point is i'm developing part of an application for college, each group member is developing a module of sorts. If each could provide their .jar the main project can just include jars and use them. I'm guessing all the mains in the jars wouldn't really hurt? But still...
You can use the project properties to customize your project's jar file content. This screenshot shows what it looks like for a Java Class Library project.