Text Editor: Geany
Compile media: Geany
Running media: Geany
Other compiling media: Terminal
Other running media: Terminal
Source code:
![]() | |
Coba1.java |
![]() | |
Coba2.java |
![]() | |
MainClass.java |
Problem 1:
I compiled MainClass.java and it gave me errors ("Cannot find symbols" for each class declaration and import statements). Originally all files (.java and .class files) were in one folder named coba.
Solution:
I created another folder in coba named coba and put the .class files of Coba1 and Coba2 inside it. It then worked!
Lesson learned:
You need to specify in the build configuration of Geany: javac -d C:\Users\rod\Documents\Personal Docs\JavaCodes\Source\coba "%f" in order to let javac create the appropriate packaging directories. See the configuration for Set Build Commands below.
When you compile a .java file with a -d option, the "package ..." statement will make the jvm create the necessary folder in the same folder as the .java file. The .class files will be stored in these new folders. If you don't use the -d option, it will put the .class files as where the .java file is.
//===========================================================
Problem 2:
In Geany, when I hit the Execute button on MainClass.java, it gives Error: COuld not find or load main class MainClass
Temp solution:
Go to Terminal, run java command on MainClass.class by using its fully-qualified name: java coba.MainClass, from directory Class.
It won't run if you run it from coba directory. It will give an Error: java.lang.NoClassDefFoundError: MainClass (wrong name: coba/mainClass). It won't run if you run it from Class directory either. It will give an Error: could mainClass)
Solution:
Go to Build > Set Build Commands and set up the Working Directory for Execute command to the folder where your classes files are located. Also, specify the fully-qualified name by adding the name of the MainClass' package. In this case, coba. Thus it becomes: java "coba.%e", like below:
![]() |
Set Build Commands configuration |
These images dont show up
ReplyDeleteThis comment has been removed by the author.
ReplyDelete