The import org.omg cannot be resolved - java

I'm following this tutorial on how to set up corba, but I can't use the packages they are talking about, and no where on the internet can give an adequate explanation of how to get them.
I want the following imports to not give me an error.
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
Downloading JacORB just gives me a github file the also has imports of the package 'org.omg'
Somebody said use this findjar site, I have no idea what the things are on that site

Be sure to download the CORBA API from a reliable source:
Glassfish
JOnAS
Add a folder to your project called lib and drag the jar file into lib
Right Click the jar file and select Build Path -> Add to Build Path
Then go to project -> properties -> libraries and move the jar to your CLASSPATH

Related

Java import error - org.jdom

I am attempting to edit code from an old developer.
I know it is bad practice but what she said I had to do was create a dummy project and then copy paste the packages in question modify what I need to modify then compile and copy the classes that I changed into the directory where the classes in use are stored.
So I created the dummy project and copied the packages/files into the source folder of the dummy project but I keep getting a "package org.jdom does not exist" error.
The error appears on the lines:
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
When I copied the folders/files into the source folder I copied the entire "org" directory.
You can see from my screenshot that the package is in the Project Explorer
I have several things to resolve the issue but none seemed to work.
I tried adding the "org" directory into the classpath environment variables.
I tried adding the "org" directory as a library to the project.
I have tried clearing the NetBeans cache after doing both of these but none of these 3 things worked.
Below is a screenshot of the projects src folder in file explorer
Can someone explain to me what I need to do to get this issue resolved?
I was adding the wrong files to the libraries section of my project.
I was adding the source for jdom when i should have been adding the jdom .jar file.
Thanks for the help guys.
install jdom at your library folder, there is a new version of jdom try to download it and install it in your project directory.

The import com.example cannot be resolved

I am trying to compile this example given by Google on the protocol buffers:
https://developers.google.com/protocol-buffers/docs/javatutorial
It comes with a ListPeople.java and AddPerson.java file along with a bunch of imports. The problem is that i am getting "The import com.example cannot be resolved" as seen in this screenshot:
http://postimg.org/image/67whg6a57/full/
This is the full path of the import com.example java file:
http://postimg.org/image/wexoc4sez/full/
and where all of my files are located:
http://postimg.org/image/4veseacpn/full/
I've tried to do the following:
Project->Clean
File->Refresh
Property->Java build path->add external JAR:
http://postimg.org/image/xjrqhievv/full/
None of these has work. What is the problem?
So this seems to be code that is missing from your project. If you press Shift-Ctrl-T and type in AddressBook, is it there?
If it is not there then it has not been generated from the example .proto files as specifiied in the Google on the protocol buffers files
You're trying to add Java source files as if they're libraries - they're not.
Add the "src" directory as a Source Path (leftmost tab in the Java Build Path settings) instead. Or if that's already a source path, try refreshing it in package explorer. Either way, you definitely don't want to have source files as libraries...

import org.apache.axis.message.MessageElement not found? which jar to import foe this?

I have opened the jws file of StatelessAuthenticationSSOToken, sample code availabe in Oracle Repository.But even after importing all the libraries it says "Import org.apache.axis.message.* not found".I already have axis.jar in my classpath beside other Apache axis1.4 libraries.
Whic other library or jars are required to be imported
If you have the jars on your classpath, check the order. You might have to change it under the Order & Export tab.

Adding Reflections library to a Eclipse project

I am trying to add Reflections library to an Eclipse Java project to use it for my needs. The problem is that although I have added reflections-0.9.9-uberjar.jar to my project's lib folder, and also to the Build Path (in fact it appears also under "Referenced Libraries"), the builder seems not to recognize it, so this line for example gives me an error:
Reflections reflections = new Reflections("net.iberdroid.gameserver.cmds");
"Reflections cannot be resolved to a type"
If I try to import org.reflections it says that it cannot be resolved neither.
Any ideas?
Thanks a lot in advance,
The quick and dirty way: open the reflections-0.9.9-uberjar.jar and extract all the jars within it to your lib folder. Then add those jars to the build path.
The more correct way would be to setup your project as a maven project and setup all the dependencies there. Take a look inside META-INF folder of the uberjar.
You may import a class:
import org.reflections.Reflections;
or all the classes in a package:
import org.reflections.*;
But you can't import a package:
import org.reflections; // looks for a class named "reflections" in the package "org"
Note that, with an IDE like Eclipse, you almost never import anything, because the IDE does it for you. Type "Refl", then Ctrl-space, and Eclipse will suggest to use Reflections and add the import for you. Or use "Reflections" without importing it, then hit Ctrl-Shift-O, and Eclipse will organize the imports by adding all the necessary imports and removing unnecessary ones.
EDIT:
The reflections-0.9.9-uberjar.jar file is not a Java library (a jar containing classes). It's a jar containing other jars (and which should thus be a zip file to avoid the confusion). You must unzip the jar and put all the libraries it contains into the build path.

NetBeans - How to import a class from an external library

I have a Java project in Netbeans and I want to use some classes from Weka within my project.
I added the file C:\Program Files\Weka-3-7\weka-src.jar into my Libraries following the instructions here (project, properties, libraries ..)
So how do I now import the classes I want?
I tried importing like this:
import weka.core.converters.ConverterUtils.DataSource;
And for kicks, I also tried this which didn't work either:
import src.main.java.weka.core.converters.ConverterUtils.DataSource;
NetBeans says "package does not exist" for both.
Have I linked the libraries incorrectly? Do I need to phrase the import differently?
Much thanks for any insight into this you can provide.
Update:
In my Libraries folder of my projects tab I see:
weka-src.jar and under that I see: , META-INF, lib, src.main.java.weka.associations, and lots of other things from weka.
I have downloaded Weka from here. I have added the JAR file you mentioned and I have also added weka-src.jar.
The problem is that although I have no problems with your first import:
import weka.core.converters.ConverterUtils.DataSource;
I can't see this package anywhere:
import src.main.java.weka.core.converters.ConverterUtils.DataSource;
To see if you have successfully imported a .jar file or a library, click on the "Projects" button on the left margin, find the Project you have added the resource to and expand the view (by pressing the + sign). You should have an item named "Libraries". If you expand that, you should be able to see the files you have added.
I was looking for how to install Weka Jar file too, and I read this tutorial and I realize that the jar file is actually on you Weka installer, and then you just need to import the jar file as same as any other library. Take a chance to look this tutorial, it is pretty cool.
http://www.cs.umb.edu/~ding/history/480_697_spring_2013/homework/WekaJavaAPITutorial.pdf
"Logic will take you from point A to point B, imagination will take you everywhere"

Categories