Hey guys , i am a beginner in Java and i got stuck while compiling a code in atom ,can anyone please help me?
I am installed the “script” package and my os is Linux mint
I would suggest that you ask someone with more Java knowledge. This forum is for people using Atom and Electron, and there probably aren’t very many Java experts who hang around here.
Thanks for the suggestion
The error in the output shows what the problem is. It’s attempting to find the class d
in the package Documents.Java
.
I can also see in the screenshot that the path of the file, relative to your project in Atom, is Documents/Java/d.java
. From this I can tell that the project you opened is the parent of the Documents
folder, which seems to be your home folder. The Documents/Java
part of the path is therefore interpreted by the script package as the Java package that your d
class is in.
The script package’s documentation says the following about using Java:
Project directory should be the source directory; subfolders imply packaging.
This is exactly what’s happening. The project that you open in Atom, in your case, should be the Java
folder. The d.java
file will then lie directly under it in your project tree.
Another way to fix this is to tell the class that it is in the package Documents.Java
by adding the following to the top of the file:
package Documents.Java;
This works due to how the Java compiler maps folders to packages, but don’t do this though. Your home folder shouldn’t have been the project folder in the first place. Rather open the Java
folder as the project as shown in the first screenshot.
Thank you so much for the solution
Sure. You’re welcome.
It might help to rather use an IDE that has good support for Java development such as Eclipse. Especially as the project gets bigger, but even for small projects it’s very convenient. Take a look at this tutorial. It’s very short and shows you how to do exactly what your code does, but with the Eclipse IDE.
what should I do? I have installed java 1.8 version