+ 1

Libraries

Hello everyone, somebody who knows how to use libraries when programming on a pc? Tried using javafx But could not figure it out sadly. Any help appreciated Regards noob programmer xD

5th Jul 2023, 2:47 PM
Marcus Brobeck
9 ответов
+ 2
The easiest way to start a JavaFX project is using an IDE which has some support for it. For example, IntelliJ Idea. https://www.jetbrains.com/help/idea/javafx.html It is important to note, that most Java developers use build tools such as Maven or Gradle, when their project relies on external libraries as dependency. This is tremendously helpful, because the build tools only need a few lines of configuration, then they automatically download the required libraries from an online repository, such as Maven Central, and it is automatically integrated with your project, without having to worry about manually downloading files and setting classpath.
5th Jul 2023, 6:11 PM
Tibor Santa
Tibor Santa - avatar
+ 1
To include external libraries when compiling Java code using the "javac" command, you need to specify the classpath. The classpath tells the compiler where to find the required libraries. Here's how you can include a library using the "javac" command: 1. Make sure you have the library file (usually a JAR file) available on your computer. 2. Open the command prompt or terminal and navigate to the directory where your Java source code file is located. 3. Use the "javac" command to compile your Java file, and include the library using ...
5th Jul 2023, 3:00 PM
Oracle Outey
Oracle Outey - avatar
+ 1
... 3. Use the "javac" command to compile your Java file, and include the library using the "-cp" or "-classpath" option followed by the path to the library file. For example: ```shell javac -cp path/to/library.jar YourJavaFile.java ``` Replace "path/to/library.jar" with the actual path to the library file on your computer. Make sure to provide the correct path, including the file extension (.jar). 4. If there are multiple libraries, you can separate them using a platform-specific separator (e.g., `;` in Windows, `:` in Linux/Mac). For example: ```shell javac -cp path/to/library1.jar;path/to/library2.jar YourJavaFile.java ``` 5. After successful compilation, you can run your Java program using the "java" command, again specifying the classpath using the "-cp" option: ```shell java -cp path/to/library.jar YourJavaFile ``` Replace "YourJavaFile" with the name of your Java file (without the `.java` extension). Remember to adjust the paths and filenames according to your needs
5th Jul 2023, 3:01 PM
Oracle Outey
Oracle Outey - avatar
+ 1
or you can save the classpath in the environment variable set CLASSPATH=%CLASSPATH%;path/to/library.jar for windows. Instead of using %CLASSPATH%; you should use $CLASSPATH: in Linux terminal. Note the $ and : signs instead of the two % Then you can skip the -cp part when compiling and running.
7th Jul 2023, 3:30 AM
Bob_Li
Bob_Li - avatar
0
Read the documentation? Unfortunately I haven't started learning Java yet. Can you clarify more?
5th Jul 2023, 2:52 PM
Oracle Outey
Oracle Outey - avatar
0
Well i have read it, but i cant get the javac command (compiling command) to include the library so i get an error
5th Jul 2023, 2:54 PM
Marcus Brobeck
0
Using…?
5th Jul 2023, 3:03 PM
Marcus Brobeck
0
I had to split and stitch it because my Sololearn answer exceeded the maximum character input. Well it should be there by now.
5th Jul 2023, 3:05 PM
Oracle Outey
Oracle Outey - avatar
0
Ohhh okey i see, i will try. Thanks very much!
5th Jul 2023, 3:06 PM
Marcus Brobeck