java “cannot find symbol” - when importing from a library - java

So I have a java project (P1) (I am using Play Framework) in which I import a jar file (I generated from a different project I have (P2) ).
I had to do few changes in project (P2) including renaming few variables. Then I regenerated the Jar file which I then imported in (P1)
However whenever I try to run my project I get the follwoing error message
cannot find symbol
Read from stdout: symbol: variable FIELD_NONSTEMMED_CONTENT
However the IDE is not showing any errors. In fact when I click on the variable FIELD_NONSTEMMED_CONTENT it redirects me to the imported class (from the JAR) which already have this variable.
So I am not sure what could be the cause of this issue.
I have read the detailed answer of the background on this error (see below), however I could not find related infromation.
https://stackoverflow.com/a/25706217/1831518
EDIT
To clarify
My IDE is intelliJ
My project (P1) is java web application built using playframework. I use Lightbend Activator build and run the project
The error message (shown above) appears when I try to build the project (P1)
Project (P2) - used to build the JAR file - is a normal java project

Related

java intellij - how to build directory-based project?

Total newbie here.
I hired a developer to create a java project using IntelliJ.
He provided me a github link and I downloaded a *zip of the project.
After unzipping, I looked in the folders and see a hidden /idea folder.
After installing IntelliJ, I then File->Open and selected the root folder of the unzip.
It appears to load in the project explorer of IntelliJ.
I even have an option for Build Project.
However, after I click the Build Project button, it does nothing. Instead I see a message in Event Log: "cannot start compiler: The SDK is not specified for module ...."
The main.java class is buried a few directories down from the root directory.
I checked the main.xml and it correctly paths to the main.java.
What am I missing to build this project?
It isn't clear to me if I selected the correct directory (the root) with the File->Open operation.
I know - very newbie question here - please don't blast me too hard in your reply. I'm probably not even asking this question in the correct manner.

Sudden total meltdown: Cannot Find Symbol, ClassNotFoundException (Java, NetBeans)

I have a java webapp (servlet), running in Tomcat; and a related external .jar library. Everything was fine, and suddenly, symbols (method names) can't be found. Even though I can run the app in netbeans, I can't build the app for deployment to the server: Build Failed; a series of Cannot Find Symbol errors related to an external .jar file, added as "library" in NetBeans. The library had been working fine and had not been changed:
.../src/java/com/shelterislandsoftware/alphascreen/screen/FeatureNumber.java:842:
error: cannot find symbol
this.formatType = SisFormat.valueOf(in.readUTF());
symbol: method valueOf(String)
location: class SisFormat
.../src/java/com/shelterislandsoftware/alphascreen/screen/FeatureNumber.java:911:
error: cannot find symbol
out.writeUTF(formatType.name());
symbol: method name()
location: variable formatType of type SisFormat
The source files of the SisFormat.java classes sit in the correct src folders they've always been in; the methods are present in the class and written correctly. Any suggestions? Thanks.
-- UPDATE: Now, I'm also unable to (re-)build an old JavaFx project. The java code has been built and working as an osx application; I wanted to change the icns image, and I can't rebuild. I doubt that the new image is the source of the build problem, just as I doubt that my (perfectly functional) java servlet code is the source of my build problem described above. I don't know for sure but I really suspect there's a problem with the new NetBeans 8.2 and / or osx Mojave. No one's interested, OK then. I've just copy-pasted the (formerly) library source classes directly into the main project described above, and this lets me build. It's suboptimal, as I'm using the same .jar file in a separate web app, so now I have two copies of the same classes to maintain. Oh, also, the same .jar that is unbuildable as an external jar now in this web app described above, is still perfectly buildable as an external jar in the other web app. Whatever.
I fixed this problem. The new osx (Mojave) and the newest Netbeans as of writing (8.2) are intolerant of certain package names. I fixed the problem by altering my package names. Specifically, I had projects (in their own project directory) and a library (in its own library directory). While these directories were distinct in the computer's file system, the subsegment of those paths that Netbeans considers to be the "package name" had a common root element. Both the project(s) and the library "package name" started out like com.mydomain followed by the specific name of the project or library. I fixed the problem by changing the library package name to "lib.mydomain", and all the funky build problems ceased.

Why java code working in Intellij Idea, but not working JAR file after building artifact

My code working well from Intellij Idea by clicking Run. But created JAR file (build artifact) doesn't run with JVM Launcher error: "A JNI error has occur, pls check your installation and try again".
Previously it's was OK with builded JAR, but recently I modified my code and made some improvements and added some external JAR files to my project (HtmlUnit, HttpClient, etc).
I suppose that problem with dependencies, but how to fix?
You haven't included whole error message. It may be either problem with dependencies (not present/found) or they signature (some java libraries are signed and the problems occurs when the archive is repacked).
I was able to fix the problem by:
Configure the archive for the project:
Choose second option: "Copy to the output directry and link via manifest"
Build artifact
The artifact will be generated in the choosen directory. Also the dependencies will be copied next to it
You can enter into the directory from command line and run the app (or create a script):

Xamarin bindings java library - No package found

Im want to link an android jar library to my Xamarin project, i do everything covered by the online doc on Xamarin website.
But when i compile the binding project i got a warning that say : No Package Found.
If i replace the desired Jar by another, let say picasso.jar for example, i don't have this error and the binding projet compile without problems.
I can't link the jar library because of an NDA engagement.
But it's possible that the problems is that i get the .jar from a repository supposed to be build by maven/gradle and not a final .jar compiled?
What can i do to track the real error behind this "no package found"
A DLL is correctly generated at the end of the process, but added it to the main project don't give me any classes from the original jar.
As I thought this is the fault to the jar from maven repository. Inside the jar we got java files and not compiled files.
So i take an compiled jar (aar files) and everything work now.

How to build imported project on Eclipse?

I just imported source folders and required libraries from another PC on which I had been working. The project contains JAVA and Python code in separate packages. Now there seems to be some problem with running the Java parts.
Error: Could not find or load main class Drivers.DependencyFinder
I have tried Cleaning and Building the project. It didn't create any classes in the bin folder. When I copied class files from the older PC, it gives some version error.
I'd like to make a fresh build, removing all the things I had earlier other than the source code. Clicking Build All or Build doesn't produce anything. What's going wrong?
Go to the project properties and check Source tab under Java Build Path. Make sure the proper folders are included in the build path.

Categories

Resources