[java] Java Package Does Not Exist Error

So there's a folder /usr/share/stuff in the root directory

in stuff there are a bunch of java files with package org.name definitions at the top

I am running javac test.java where test.java is in a subdomain

I added /usr/share/stuff to my class path.

and at the top of test.java I add import org.name

But I get a package does not exist error...why?

This question is related to java import package

The answer is


I had the exact same problem when manually compiling through the command line, my solution was I didn't include the -sourcepath directory so that way all the subdirectory java files would be compiled too!


You should add the following lines in your gradle build file (build.gradle)

dependencies { 
     compile files('/usr/share/stuff')
     ..
}

If you are facing this issue while using Kotlin and have

kotlin.incremental=true
kapt.incremental.apt=true

in the gradle.properties, then you need to remove this temporarily to fix the build.

After the successful build, you can again add these properties to speed up the build time while using Kotlin.


Right click your maven project in bottom of the drop down list Maven >> reimport

it works for me for the missing dependancyies


I was having this problem, while trying to use a theme packaged as .jar in my app, it was working while debugging the app, but it didn't when building/exporting the app.

I solved it by unzipping the jar, and manually add its contents to my build folder, resulting in this:

project/
   ¦
   +-- build 
   ¦   +-- classes
   ¦       +-- pt
   ¦       ¦   +-- myAppName ... 
   ¦       +-- com
   ¦           +-- themeName ...
   +-- src
   +-- lib

I don't have the error anymore and my app loads with the intended theme.


You need to have org/name dirs at /usr/share/stuff and place your org.name package sources at this dir.


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to import

Import functions from another js file. Javascript The difference between "require(x)" and "import x" pytest cannot import module while python can How to import an Excel file into SQL Server? When should I use curly braces for ES6 import? How to import a JSON file in ECMAScript 6? Python: Importing urllib.quote importing external ".txt" file in python beyond top level package error in relative import Reading tab-delimited file with Pandas - works on Windows, but not on Mac

Examples related to package

ModuleNotFoundError: No module named 'sklearn' Python: How to pip install opencv2 with specific version 2.4.9? Relative imports - ModuleNotFoundError: No module named x Is __init__.py not required for packages in Python 3.3+ "pip install unroll": "python setup.py egg_info" failed with error code 1 Unable to Install Any Package in Visual Studio 2015 beyond top level package error in relative import How can I specify the required Node.js version in package.json? "installation of package 'FILE_PATH' had non-zero exit status" in R Error in installation a R package