Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Can't javac my file

  1. #1
    Junior Member
    Join Date
    Apr 2024
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Can't javac my file

    Sorry if i look really stupid, but i started with java today. I tried to write a simple "Hello World" and i did it, but when i go to terminal and type
    javac HellWorld.java it gives me this:

    Traceback (most recent call last):
    File "/usr/lib/command-not-found", line 27, in <module>
    from CommandNotFound.util import crash_guard
    ModuleNotFoundError: No module named 'CommandNotFound'

    I would really appreciate if you help me.

    (I use Linux Mint MATE 21.3)

  2. #2
    Member
    Join Date
    Jan 2024
    Posts
    75
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Can't javac my file

    It seems like you're encountering an error related to the Python `command-not-found` package rather than a Java-specific issue. This error suggests that the `javac` command is being interpreted as a Python script, which is causing confusion.

    To resolve this, you can try explicitly specifying the Java compiler by providing the full path to the `javac` executable. Typically, `javac` is located in the Java installation directory. You can find the location by running the following command in your terminal:

    ```bash
    which javac
    ```

    This command should output the full path to the `javac` executable. Once you have the path, you can use it to compile your Java file. For example, if the output of the `which javac` command is `/usr/bin/javac`, you can compile your `HelloWorld.java` file like this:

    ```bash
    /usr/bin/javac HelloWorld.java
    ```

    Replace `/usr/bin/javac` with the actual path you obtained from the `which` command.

    If you haven't installed the Java Development Kit (JDK) yet, you'll need to do so. You can install it using your Linux distribution's package manager. For example, on Debian-based systems like Linux Mint, you can install OpenJDK, which includes the Java compiler (`javac`), using the following command:

    ```bash
    sudo apt install default-jdk
    ```

    Once the JDK is installed, you should be able to compile your Java files without encountering the Python-related error. If you continue to face issues or need further help with Java assignment, feel free to seek help from resources such as online programming assignment help platforms like ProgrammingHomeworkHelp.com. They can provide guidance and support tailored to your specific needs.

Similar Threads

  1. javac
    By Prawnja in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 2nd, 2020, 06:11 PM
  2. Have problem with javac
    By AleksandraVulisic in forum What's Wrong With My Code?
    Replies: 5
    Last Post: September 9th, 2017, 09:11 AM
  3. JAVAC
    By iansmiler in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 27th, 2012, 03:45 PM
  4. Do I have to keep setting the path file for javac?
    By fallout87 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 24th, 2011, 07:33 PM
  5. javac help
    By mjpam in forum Java Theory & Questions
    Replies: 7
    Last Post: February 16th, 2011, 10:46 AM