I've code on Java since three months. I started with Intellij Idea, but it's so heavy for my computers, so I've decided code using jEdit.
But many software that I've programmed it's in the way of Intellij, so I oppened my programs on jEdit.
As usual like me, I create a principal class that calls to next class into an Object like the next way:
W1 ejectuar = new W1 ;
But on jEdti prints the next error:
INDT.java:10: error: cannot find symbol
W1 ejecutar = new W1() ;
^
symbol: class W1
location: class INDT
INDT.java:10: error: cannot find symbol
W1 ejecutar = new W1() ;
^
symbol: class W1
location: class INDT
2 errors
Intellij create the class into a package, but I don't know how to link the both class to compile.
Call javac -cp . classname.java instead of javac classname.java and it should work.
Related
When I try to call Programmer class from Main class an error comes up, saying that it cannot find symbol Programmer.
NOTE : Programmer.java and Main.java are in the same folder (package).
Main.java
public class Main{
public static void main(String[] args) {
// Scanner scann = new Scanner(System.in);
Programmer john = new Programmer();
System.out.println(john);
}
}
Programmer.java:
public class Programmer {
String language = "java";
String framework = "Spring";
}
Result of java main.java command
main.java:8: error: cannot find symbol
Programmer john = new Programmer();
^
symbol: class Programmer
location: class Main
main.java:8: error: cannot find symbol
Programmer john = new Programmer();
^
symbol: class Programmer
location: class Main
2 errors
error: compilation failed
Single file mode, where you just type 'java YourClass.java' needs all of the dependencies compiled first.
javac Main.java
java Main
That should get your program running, and to compile the additional class file. If you prefer to use the single source file.
javac Programmer.java
java Main.java
Should work although if you have a leftover main.class on your class path you could have an issue.
**This is for java 11 and later when single source mode was introduced.
Relatively new to Java - I just one to update ONE file inside a JAR file. I've decompiled the JAR, and have access to the Java file.
I am trying to use javac, however when I am using it, it throws errors as it doesn't have references to various dependencies.
Do I need to compile everything to get rid of these? Is there a simple way to just compile the one file?
javac MessageNotificationService.java
...
MessageNotificationService.java:108: error: cannot find symbol
List<EmailNotification> pendingEmails = this.messageDao.findPendingNotification("merchant", "new_message");
^
symbol: class EmailNotification
location: class MessageNotificationService
MessageNotificationService.java:111: error: cannot find symbol
List<Long> ids = pendingEmails.stream().map(EmailNotification::getId).collect(Collectors.toList());
^
symbol: variable EmailNotification
location: class MessageNotificationService
MessageNotificationService.java:182: error: cannot find symbol
for (EmailNotification notification : pendingEmails) {
^
symbol: class EmailNotification
location: class MessageNotificationService
39 errors
Sorry if this is a basic question - all of the search results on this seem to be for self-contained files that don't have errors like this.
As far as I can tell, you just point to the old JAR file
javac -cp "./old-jar-file-1.0.0.jar" ./location-of-file/MessageNotificationService.java
I've looked everywhere and I seemingly tried everything. I can't get rid of this error. First, my code. The directory in my computer matches the one in the GitHub link, replacing Pset2:/ with W:/, here is all the code:
https://github.com/MichaelGordonII/JavaCS50/tree/master/pset2
In command prompt I use the following command:
W:/Mario/src:>javac -cp w:/Mario/src/output Mario.java
This gets me the error. I have tried other tags with the same results. I've even tried IntelliJ IDEA 15 Community and it always says I don't have an SDK. I've beat my head on a wall enough, I just need someone else's eyes.
EDIT: Error message:
W:/Mario/src>javac mario.java
mario.java:5: error: package w.mario.src.output does not exist
import w.mario.src.output.OuputToFile;
^
mario.java:6: error: package w.mario.src.output does not exist
import w.mario.src.output.OutputToConsole
^
mario.java:23: error: cannot find symbol
OutputType outputCommand = (desiredOutputType.equals("textfile")) ? new OuputToFile() : new OutputToConsole();
^
mario.java:23: error: cannot find symbol
OutputType outputCommand = (desiredOutputType.equals("textfile")) ? new OuputToFile() : new OutputToConsole();
^
symbol: class OutputToFile
location: class Mario
mario.java:23: error: cannot find symbol
OutputType outputCommand = (desiredOutputType.equals("textfile")) ? new OuputToFile() : new OutputToConsole();
^
symbol: class OutputToConsole
location: class Mario
5 errors
You are either missing one of these : JDK_HOME, JAVA_HOME. Look at this link
I have SimpleSphere.java and TestClass.java stored in a folder called MyPackage.
Attempting to compile TestClass gives this error:
TestClass.java:7: error: cannot find symbol
SimpleSphere ball = new SimpleSphere(19.1);
^
symbol: class SimpleSphere
location: class TestClass
TestClass.java:7: error: cannot find symbol
SimpleSphere ball = new SimpleSphere(19.1);
^
symbol: class SimpleSphere
location: class TestClass
2 errors
But I am fairly certain I have everything set up correctly (evidently I do not, and yet I remain stubborn!). Also, even if these two files were not part of MyPackage, shouldn't JAVA look in the current directory as default and find SimpleSphere???
Seems that you're compiling the classes directly using javac ClassName.java inside the folder where they are located. You have to move one folder up and compile them since there.
Here's a sample of how the files should be located
- basePath
- MyPackage
+ SimpleSphere.java
+ TestClass.java
In your cmd/shell:
# [basePath] javac MyPackage/SimpleSphere.java
# [basePath] javac MyPackage/TestClass.java
# [basePath] java MyPackage.TestClass
Try moving one folder up and then compiling.
Best of Luck.
So, I'm actually coding primarily in python, but I need to do one thing in java, and having no java experience, I'm really not understanding how this works.
My program creates java files, then compiles them with command prompt, and puts them into the minecraft.jar, but I don't really understand what I need to write in command prompt to set the classpath to the minecraft.jar. Especially because I need this to work on everyone's computer, and I won't know where my program (and thus the java files) are.
Could anyone give me a hand with this?
Edit:
Okay, so I tried doing this:
javac -classpath %appdata%\.minecraft\bin\minecraft.jar BLOCK1.java
And it gives me this error:
LLBLOCK1.java:3: error: cannot find symbol
public class LLBLOCK1 extends Block
^
symbol: class Block
LLBLOCK1.java:5: error: cannot find symbol
private World worldObj;
^
symbol: class World
location: class LLBLOCK1
LLBLOCK1.java:12: error: cannot find symbol
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
^
symbol: class World
location: class LLBLOCK1
LLBLOCK1.java:12: error: cannot find symbol
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
^
symbol: class EntityPlayer
location: class LLBLOCK1
LLBLOCK1.java:9: error: cannot find symbol
super(i, j, Material.wood);
^
symbol: variable Material
location: class LLBLOCK1
LLBLOCK1.java:14: error: package Block does not exist
world.setBlockWithNotify(i + 0, j + 0, k + 0, Block.stone.blockID);
^
6 errors
Am I writing the classpath wrong?
the minecraft.jar is almost always located in
C:\Users\User_Name\AppData\Roaming\.minecraft\minecraft.jar
In batch language you can use:
%appdata%/.minecraft/minecraft.jar
However you may want to also back it up first, copy and rename the minecraft.jar so if anything goes horibly wrong you can always restore it easier.
If you are compiling the jar, you can type in the location of the output for the jar:
-jar cvfm c:/users/matt/documents/Minecraft.jar manifest.txt *.class
I believe this would work if you were to create your own jar. This would be easier then directly editing the Minecraft jar.