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 1 of 1

Thread: running javac at lower level on a Fedora box --encountering problems

  1. #1
    Junior Member
    Join Date
    Dec 2023
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default running javac at lower level on a Fedora box --encountering problems

    I used the alternatives --config command to select the more recent version of Java that matched my javac or java-devel.

    [~]$ sudo alternatives --config java

    There are 3 programs which provide 'java'.

    Selection Command
    -----------------------------------------------
    *+ 1 java-17-openjdk.x86_64 (/usr/lib/jvm/java-17-openjdk-17.0.9.0.9-1.fc39.x86_64/bin/java)
    2 java-latest-openjdk.x86_64 (/usr/lib/jvm/java-21-openjdk-21.0.1.0.12-1.rolling.fc39.x86_64/bin/java)
    3 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.21.0.9-1.fc39.x86_64/bin/java)

    Enter to keep the current selection[+], or type selection number: 2

    [~]$ cd javajar/javascripts
    [javascripts]$ javac helloworld.java
    [javascripts]$ ls
    helloworld.class
    helloworld.java
    [javascripts]$ java helloworld.java
    Hello World

    Now works...
    [javascripts]$ java helloworld
    Hello World
    [javascripts]$



    1. Fedora 39: Linux 6.6.4-200.fc39.x86_64

    2. javac version: javac 21.0.1, I vaguely recall downloading a new version while troubleshooting a Selenium issue. I think it was because I installed java-devel with this command:
    sudo dnf install java-latest-openjdk-devel

    3. java version:
    openjdk 17.0.9 2023-10-17
    OpenJDK Runtime Environment (Red_Hat-17.0.9.0.9-2) (build 17.0.9+9)
    OpenJDK 64-Bit Server VM (Red_Hat-17.0.9.0.9-2) (build 17.0.9+9, mixed mode, sharing)

    4. cat helloworld.java
    public class helloworld {
    public static void main(String[] args) {
    System.out.println("Hello Worlld");
    }
    }

    5. javac helloworld.java
    6. ls
    helloworld.java
    helloworld.class

    7. So, no helloworld file
    8. java helloworld.java
    Hello Worlld

    9. Should there not also be a helloword file that was created with the javac command?

    10. java helloworld
    Error: LinkageError occurred while loading main class helloworld
    java.lang.UnsupportedClassVersionError: helloworld has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0

    11. So, I decided to recompile using the source and target options of javac.

    12. javac -source 17 -target 17 helloworld.java
    warning: [options] system modules path not set in conjunction with -source 17
    1 warning

    So, what's happening? I am compiling from the command line, not from an IDE. I don't want to mess with trying to upgrade the JDK or JRE to version 21. How do I get the javac command to compile with version 17? I tried to find out how to find the system modules path, but came up short.
    Last edited by mgdjava; December 13th, 2023 at 04:35 PM. Reason: I found the solution!

Similar Threads

  1. How to create math problems by grade level. Please Help Me.
    By Mata101Alex in forum What's Wrong With My Code?
    Replies: 43
    Last Post: June 15th, 2014, 01:58 PM
  2. Running error Javac
    By ISHRAT JAHAN in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 17th, 2013, 03:12 AM
  3. [SOLVED] n00b having problems running code
    By cha0s619 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 10th, 2012, 04:31 PM
  4. Problems with running and compiling application
    By set_lugaru in forum Java Theory & Questions
    Replies: 4
    Last Post: July 3rd, 2012, 04:26 PM
  5. Finding college level problems
    By DougFane in forum The Cafe
    Replies: 1
    Last Post: February 2nd, 2012, 08:44 AM