This question already has answers here:
What does a "Cannot find symbol" or "Cannot resolve symbol" error mean?
(18 answers)
Closed 5 years ago.
Edit: This is not a duplicate because the other thread contains solutions and suggestions based on correcting syntax within my code. My code compiles and runs just fine within an IDE, as I already stated in the original post. I am simply placing this statement at the top so that it will not be missed by do-gooders who get too excited about the chance to mark duplicates and forget to read content. Gosh I love stackexchange.
Good afternoon! I am trying to refresh my Java skills after a lot of years off, and I am following along with an online textbook.
The textbook suggested that readers get familiar with command line usage, which wasn't really emphasized in college. One of the tasks was to drag two java classes into any working directory, compile and run them with javac and java commands.
javac TextIO.java
works great.
javac NewWorld.java
produces 12 identical errors:
error: cannot find symbol
symbol: variable TextIO
location: class NewWorld
TextIO is the class with some subroutines that read and write to wherever. NewWorld is the main class with some little hello world type stuff that reads input and writes to a file with the TextIO class.
Help me help myself understand the command line environment. Let me know if you need more details!
What does a "Cannot find symbol" compilation error mean?
Possible issues:
Incorrectly spelled
Forgot to import
Forgot to declare something
etc.
The most possible case of this behavior I may think of is that you didn't set CLASSPATH Environment Variable in your operating system yet. When working with IDEs, like Eclipse, they take care of it and you don't need to worry about it. There are many tutorials online pointing how to correctly set a CLASSPATH in your operating system step by step, just google for setting CLASSPATH for JRE and you find how to set it step by step. You can set it through the proper commands in command line, here are some informations about how to set it properly:
https://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html
Related
This question already has answers here:
How to find the real class name from obfuscated ProGuard classname in my source code?
(1 answer)
Android - How to check Proguard obfuscation has worked?
(5 answers)
Closed 1 year ago.
I am seeing a bunch of ClassCastException crashes in my project and the stacktrace describing:
java.lang.ClassCastException: j.u.v cannot be cast to kotlin.collections.MutableList
I can't seem to figure out or find what the j.u.v. stands for.
Anyone?
I overlooked for a moment that j.u.v. of course seems to point to an obfuscated classname..
As to #RyanM question. That post you linked to there isn't that helpful for most people. This one is way better: Android - How to check Proguard obfuscation has worked?
For who wants to figure out to what class the obfuscated classname refers to you can either check the mappings.txt file in the build -> outputs -> mapping folder.
Or another way to figure out to which the obfuscated file/method name relates to is use the apk analyzer (build -> Analyze APK)
This question already has answers here:
- Syntax error on token ".", # expected after this token
(4 answers)
Closed 2 years ago.
This is code with the error.
IDE: Eclipse
EDIT: I used addArguments but the error still there,
Based on the documentation, the method name should be addArguments not AddArgument. By the way, Java uses camelCase for methods by convention. The code you currently have is a correct C# code, so it seems that you've copied a C# snippet from somewhere.
If the error still exists, try clean & rebuilding the project or restarting the IDE and/or your PC. It might be that "Eclipse" just have some weird problem.
You wrote the name of the function incorrectly, it is options.addArguments("--incognito");
I was working on a text-analysis project in R and needed a stemmer. I found a JAR-file of a java compilation of a snowball stemmer. Documentation:
http://lucene.apache.org/core/3_0_3/api/contrib-snowball/
Download link (bottom link):
http://www.java2s.com/Code/JarDownload/snowball/
Now, as far as I could tell, this R code should make a new stemmer object:
library(rJava)
.jinit("D:\\myUser\\Documents\\snowball.jar")
stemmer <- .jnew("org.tartarus.snowball.ext.EnglishStemmer")
However the final line of code gives the following error:
Error in .jnew("org.tartarus.snowball.ext.EnglishStemmer") :
java.lang.ClassNotFoundException
After spending quite a lot of time on this (among others, reading the following post for help: https://darrenjw.wordpress.com/2011/01/01/calling-java-code-from-r/), I got stuck because I am not sure what the exact problem is. As far as I can tell, it could be in order of likelyhood:
1. a mistake in my code
2. an issues with dependancies
3. the JAR file is corrupted somehow
Can anyone give me some pointers on where the problem might lie?
Edit: answered, see comments. The class names in this specific jar-file are lowercase.
Im trying to run this code at http://zetcode.com/tutorials/javagamestutorial/puzzle/
1 error found:
File: /Users/java/PuzzleEx.java [line: (no source location)]
Error: File is in the wrong directory or is declared part of the wrong package. Directory name 'java' does not match package name 'zetcode'.
Please help, how do I run it?
Well, first you need to compile it using javac, then you could run it. However, I'd suggest doing nothing of the sort. Just browsing through the link you provided, I'm seeing some bad practices, and outdated code (not declaring variables as interfaces, stuffing all the classes in one file, etc). Instead of following some third party, potentially outdated, tutorial, take a look at the official tutorials: https://docs.oracle.com/javase/tutorial/
Not only are the official tutorials always up to date, but they're also laid out in easy-to-follow trails and paths.
Edit:
Also, the reason it's not working is exactly as the error says: it's in a different folder than its package is declared to be. If you don't know what a package is, please take a step back and learn the basics first.
What is the correct way to import Java bean shell files into Eclipse? I want to use eval so I copied the files from an app that my friend paid for but he did not get the source files. Anyway, when I did that, I got so many errors like 'syntax error on token interface', 'implicit super constructor undefined', 'constructor call must be the first statement in a constructor', and a bunch of other errors. Any help you give is appreciated.