Why this javac: File Not Found error?
You shouldn't set your classpath to point to your JDK bin directory -- instead it should be the PATH environment variable, which serves a different purpose to classpath. (The classpath defines a list of jars and directories containing compiled Java .class code; the PATH variable defines a list of paths where the shell needs to look and locate programs to execute when they are not found in the current directory -- so if you type for instance zip
-- it would look in all the directories defined in PATH
and figure out that zip
program is located under /usr/bin
)
Secondly if you want to compile sources from both directory you need to specify:
- all the paths where the sources are (both
home/pathToFolderA/src
andhome/pathToFolderB/gen-java
) - the path where the compiled .class files to be generated
- specify in the classpath any library you might use in your source files
To sum it up, it would be something like this to compile:
javac -d /home/pathToFolderWithResultsOfCompilation -classpath /path/to/some.jar:/path/to/another.jar home/pathToFolderA/src/*.java home/pathToFolderB/gen-java/*.java
and to run your compiled programs:
java -classpath /path/to/some.jar:/path/to/another.jar:/home/pathToFolderWithResultsOfCompilation full.name.of.your.Java
I could not understand why javac: file not found: HelloWorld.java
You seem to have never used the command prompt before. The command prompt has a "current directory", just like in a file explorer window, there is a "current directory", the directory that you are viewing right now.
The current directory is usually shown just to the left of the caret.
The current directory on the above photo is C:\Users\Mrhope
.
Type dir
to see all the files and directories of the current directory. You can then use cd
to navigate to a subdirectory. Say you are in Documents
now, and you can do this
cd Project
to go to the Project
folder. By the way ../
means the parent directory
The HelloWorld.java
in javac HelloWorld.java
is a path relative to the current directory, so this will only work if HelloWorld.java is in the current directory. You should try to use cd
to navigate to the correct directory then use that command.
Setting the PATH
environmental variable is quite irrelevant here because that is setting the path of the JRE. Please set it back.
I suggest you learn the basics of cmd
first. Many tutorials are available online.
javac: file not found in Ubuntu Java
Try this:
javac -cp .:libs/java-json.jar ./src/edge.java ./src/median_degree.java
as the source files are not part of the class path and needs to be supplied as source files using the full path.
Related Topics
Any Good Orm Tools for Android Development
How to Programmatically Set Drawableleft on Android Button
Tomcat 7: How to Set Initial Heap Size Correctly
Eclipse Release Heap Back to System
Run Custom Textsecure (Signal) Server
Local_Policy.Jar and Us_Export_Policy.Jar Different with Unlimited Strength VS Default
No Swt-Mozilla-Gtk-4332 in Java.Library.Path
Shuffle Multiple Files in Same Order
How to Check If an App Running on Android
Android How to Draw a Smooth Line Following Your Finger
Android Studio 3.1.3 Gradle Sync Error. Could Not Download Gradle-Core.Jar
How to Check If a File Is Open by Another Process (Java/Linux)
Connecting to Access Database from Linux
A Simple Way of Embedding a Video in My Swing Gui