Play Framework doesn't find package on clean project - java

I created a new project on Play Framework 2.3.2 with Scala. I added two packages models and utils. Created a class in each package and made an import into the model from utils and I get this error :
[error] /media/hadareanrares/Media/Projects/TestingScala/app/models/Page.scala:3: not found: object utils
[error] import utils._
[error] ^
[error] one error found
Tried "_root_.utils._" and I'm getting the same result.

I seem to have fixed it by juggling with the class in the utils package.
I saw that IDEA IntelliJ detected the class in utils by importing as import _root_.ClassName, disregarding the utils package.
Then I moved ClassName to the root package, app. The compiler complained that it couldn't import _root_. so I moved the class back to the utils package and it seemed to have fixed it somehow after a rebuild.
The key thing that made it work was dragging the class from root to the utils package. It seemed to have updated links everywhere. But, have I not had the help of IDEA, how else would I fix this? I would like to use a simpler text tool, Sublime, that doesn't have the Scala integration that IDEA has.

You can try
activator reload // Reload the current application build file
and
activator update // Update application dependencies
then
activator idea // to recreate your IntelliJ files

I figured it out.. class in utils package didn't have "package utils" specified. Done.

Related

Java JPMS: `package xxx is not visible`

I have a simple Java project using the non-modularized dependency "io.prometheus:simpleclient_hotspot:0.16.0". It has been working fine until, for other reasons, I wanted to use the Java module system and add a module-info.java to my project. Once I do that, I start getting the compilation error:
error: package io.prometheus.client is not visible import io.prometheus.client.CollectorRegistry;
^ (package io.prometheus.client is declared in the unnamed module, but module simpleserver does not read it)
The prometheus client library isn't modularized, so it is called an "unnamed module". How do I get access to the packages of such a library? I assume I add a dependency in my module-info.java?
This seems like a basic, common JPMS newbie issue, but after doing lots of searches I can't find the solution to this issue.

Can't import class from jar file in IntelliJ

So I am trying to import this class from my jar file. IntelliJ recognizes access to all the folder structures but not the class.
Says: "Cannot resolve symbol 'Constants'.
Note that I have tried clicking "Add library 'premiumdue.main.jar' to classpath" and it still doesn't work.
I have no idea why it won't let me import the class.
Here is a minimal intellij project showing my issue: https://www.dropbox.com/s/xzvv2x1ca2lld26/jar_issues.zip?dl=0
For your sample Gradle project, the dependency jar has to be referenced in build.gradle file as described in this answer.
dependencies {
implementation files('../create_jar.jar')
}
Proof:

Android Studio Generate JavaDoc errors

I am attempting to generate a JavaDoc for my project. To do so, I use Tools > Generate JavaDoc. I check Whole Project and set the output directory. It starts to work then returns with
error: package android.content does not exist
import android.content.Context;
Along with a bunch of other package does not exist errors and
cannot access ViewGroup
public class MainMenu extends AppCompatActivity {
^
class file for android.view.ViewGroup not found
Thus far I haven't been able to find any sort of solution. My project builds and runs fine on both the emulator and actual devices. Any thoughts? Thanks!
I was able to find a work around. I loaded my project in intelliJ IDEA, and while it still showed those errors, it still was able to generate the javadoc that correctly contains all the classes and methods needed.

The import x.x.x cannot be resolved with Maven

I have a project that exports a package for another project to import and utilize. Within Eclipse, it seems to resolve correctly. But when building with Maven, I get the following errors: The import x.x.x cannot be resolved. I've fiddled around with the manifest/ pom.xml and restarted Eclipse several times and the results are the same.
The general structure is:
com.my.company.plugin
- com.my.company.pkg
And within that manifest.mf, I have Export-Package: com.my.company.pkg
For the other plugin's manifest, I have Require-Bundle: com.my.company.pkg;resolution:=optional (I've tried taking the option portion out, but that didn't seem to matter)
And within the source for the second plugin, I have:
import com.my.company.pkg.MyClass
public class MyOtherClass implements MyClass {
Locally in Eclipse it all works fine. But when I try to build with Maven, I get the following error:
[ERROR] import com.my.company.pkg.MyClass;
[ERROR] ^^^^^^^^^^^^^^^^^^
[ERROR] The import com.my.company.pkg cannot be resolved
[ERROR] public class MyOtherClass implements MyClass {
[ERROR] ^^^^^^^
[ERROR] MyClass cannot be resolved to a type
The strange thing is that I have other imports within MyOtherClass that reference other plugins and added in the Required-Bundles. I'm guessing it's how I'm exporting the first plugin. What exactly am I missing?
---EDIT---
It seems like adding this block in the parent pom is causing it to fail. Which is odd because I thought it by setting it to ignore it will completely ignore the optional dependencies instead of trying to resolve it? While taking it out causes other areas that uses optional dependencies to fail...
<dependency-resolution>
<optionalDependencies>ignore</optionalDependencies>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.ui</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.eclipse.ui.views</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>

Using Breeze in IntelliJ

I downloaded breeze jar files from the link, then I went to Project Structure->Modules->Dependencies and added downloaded jar files.
I made a new project->Scala class and wrote the following code:
import breeze.linalg_
object Scrpting extends App{
println("hello")
}
I get the following error.
Error:(4, 8) not found: object breeze
import breeze.linalg_
I tried to search online, but was unable to find any clear useful resource on how to use breeze with IntelliJ. Can someone please help me with this? I am using Mac OS.
In your build.sbt file, make sure you add all the dependencies listed under "libraryDependencies" at
https://github.com/scalanlp/breeze

Categories