New to Replit. Having problems executing code

I created a new file and code, but unable to execute the code.*

Repl link:

public class FloatingPoint {
  public static void main(String[] args) {
    float sampleFloatValue = 0.123456789f;
    double sampleDoubleValue = 0.123456789;
    System.out.println("Value as float:  " + sampleFloatValue);
    System.out.println("Value as double: " + sampleDoubleValue);

This is the error I get:

 sh -c javac -classpath .:target/dependency/* -d . $(find . -type f -name ‘*.java’)
./ error: class, interface, enum, or record expected
1 error
exit status 1

I can only seem to run the code if I edit the Main. java file

1 Like

Hey @PeterH17, welcome to the community!

Running the file is intentional, since the Repl is only expected to run one file at the time, usually the main one.

You can change which file you can run, but it’s very technical and not recommended. So instead, I suggest you to import the file into your like so:

import fp.FloatingPoint;

// …

package fp;

// …
1 Like

Hey savardo,

Thank you for your advice. That makes sense.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.