Importing a JAVA package doesn't exist - java

I am having a problem with a Java Class which keeps saying me the package I am trying to import doesn't exist but as you can see the package exist. The package name is SecuGen and it exist in the folder.

check your classpath in your IDE.
do a clean and build

Related

how to import classes from another package in java

I have a class Student_results in the package Students_Record and I want to import that to a class in the package Forgot. I have:
package Students_Record;
public class Student_results extends javax.swing.JFrame {
and
package Forgot;
import Students_Record.Student_results;
It says "package Students_Record does not exist".
Edit.
I am using NetBeans IDE 8.2.
Both project folders are in my "NetBeans Projects" folder.
What am I doing wrong? Thanks.
On your project Forgot click right -> build path -> projects. Add your project here (i.e import Students_Record).
Your import statement is correct.
Possible cause
pre-compiled import issue.
[if using plain text editor like notepad then compile Students_Record first using javac and then compile class in Forgot.
detailed ref : Importing java classes text editor
[if using IDE like eclipse then click save all in toolbar.]
those packages might be in different projects. provide folder location as asked by #TheScientificMethod.
if you are trying to import from jar then make sure of your classpath values.
[if using plain text editor like notepad then set classpath value.]
[in case of eclipse IDE, refer build path by checking Properties
section.]
Note- Always follow standard programming conventions for any programming language. Correct your package, class names accordingly.
Reference - https://www.oracle.com/technetwork/java/codeconventions-150003.pdf,
https://www.oracle.com/technetwork/java/javase/overview/codeconvtoc-136057.html

How to import file from other folder in java?

I have just started learning java, so struggling in very basics. The problem i am facing currently is "cannot find symbol : class Ques". I have resolved this issue when i was accessing package from parent directory through CLASSPATH export. Now problem is i am trying to access sub-directory from sub-driectroy like this:
family.of.adam(has)/
father.java
WifeOne(sub-direc)/wifeone.java,ChildFromWifeOne.java
WifeTwo(sub-direc)/wifetwo.java,ChildFromWifeTwo.java
Now what i am trying to do is from wifetwo.java i am accessing wifeone.java. I have tried importing (wifeone)like this:
import family.of.adam.WifeOne.*;
import WifeOne.*;
In both cases it failed to import and same error occured which i mentioned above.
I have also tried solution provided in this Question but this effects classpath of WifeOne this is what i think because when i -cp method it starts showing errors related to wifeone.
I am using normal texteditor, compiling through terminal and using mac. Kindly brief me what mistake i am doing.
Assume src is your base folder(place you compile and run the program).
src/family/of/adam/FirstWife.java
if so you need to define the package startmetn the fist line of the FirstWife.java file.
package family.of.adam;
Then,If the second java file in the,
src/Main.java
In Main.java file you need to define the import statement for user the FirstWife.java class.
import family.of.adam.FirstWife;

error package org.python.util does not exist, compilation with ant

I am trying to call a python method in java, similar functionality as Unresolved import org.python / working with jython and java?
However, I am using ant to compile and run my files. using import org.python.util will give me this error
package org.python.util does not exist
I can see that python.org.util exists in jython-2.5.0.jar.
So, here is the class path I have in my build.xml ant file:
classpath="${java.class.path}:./jgrapht/lib/jgrapht-jdk1.5.jar:\
./jgrapht/lib/jgraph.jar:./jgraphx/lib/jgraphx.jar:\
./jython/lib/jython-2.5.0.jar:./colt/lib/colt.jar:."
and I also I added the path to jython jar files to my class path. i.e. looks like echo $path gives me all the required paths. Is there anything missing here that I am not aware of?
Try this to make all classes in the package available:
import org.python.util.*;
Or this to include a particular class:
import org.python.util.TemplateAntTask;
EDIT: Also, looks like there is an extra slash after jython-2.5.0.jar in your classpath.

Problem with the import of packets in antlrworks

Have to create a package defined by me, containing some of the classes, and I recall that package in a file .java created of the program AntlrWorks in which i did the import. Package named "com.project.redfox" . I compiled the code with the command: "javac Test.java provaParser.java provaLexer.java" but I get the error that not exist the package.
In the grammar have added :
grammar prova;
#hader{
import com.project.redfox;
}
....something......
I created the package "com.project.redfox" within of the project redfox developed in NetBeans, therefore the directory com/project/redfox is in the directory redfox.
how can I solve this problem?
To formally answer your question: javac can't find the package com.wikirates which you are probably using in com.project.redfox.
Note that I assumed redfox is a class. If it's a package, you need to import all classes from it like this: import com.project.redfox.*; instead of import com.project.redfox; (assuming that there are classes in com.project.redfox...).

Importing a Java Package in root directory

I am in a sub domain subdomain.site.com and there is a java package higher up in the root directory at /usr/share/sphinx/api/java.
The typical thing to do to import this package would be to write
import sphinx.api.java;
However when I just do that, I get a package does not exist error.
What's the solution to this? Some sort of path definition?
(Im on Linux CentOS)
That isn't a package, that is a directory structure. I seriously doubt that is a actual package definition. If a class is there, it probably is in the default package which in the newer JDKs can't be imported.
you're missing the semi-colon at the end of the line:
import sphinx.api.java;

Categories

Resources