Java Package Does Not Exist Error

前端 未结 7 1192
执笔经年
执笔经年 2020-12-03 04:50

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 t

相关标签:
7条回答
  • 2020-12-03 04:55

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

    0 讨论(0)
  • 2020-12-03 04:56

    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!

    0 讨论(0)
  • 2020-12-03 04:58

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

    it works for me for the missing dependancyies

    0 讨论(0)
  • 2020-12-03 05:01

    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.

    0 讨论(0)
  • 2020-12-03 05:16

    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.

    0 讨论(0)
  • 2020-12-03 05:20

    Are they in the right subdirectories?

    If you put /usr/share/stuff on the class path, files defined with package org.name should be in /usr/share/stuff/org/name.

    EDIT: If you don't already know this, you should probably read this: http://download.oracle.com/javase/1.5.0/docs/tooldocs/windows/classpath.html#Understanding

    EDIT 2: Sorry, I hadn't realised you were talking of Java source files in /usr/share/stuff. Not only they need to be in the appropriate sub-directory, but you need to compile them. The .java files don't need to be on the classpath, but on the source path. (The generated .class files need to be on the classpath.)

    You might get away with compiling them if they're not under the right directory structure, but they should be, or it will generate warnings at least. The generated class files will be in the right subdirectories (wherever you've specified -d if you have).

    You should use something like javac -sourcepath .:/usr/share/stuff test.java, assuming you've put the .java files that were under /usr/share/stuff under /usr/share/stuff/org/name (or whatever is appropriate according to their package names).

    0 讨论(0)
提交回复
热议问题