0

When I try to open a java file I get an error :

could not find or load main class + location of the file

I'll give an example , let's say I have a file.java in my C:\Program Files\Folder.

When i'll try to open that file it'll say :

Could not find or load main class C:\Program Files\Folder\File.java

I looked all around google and I found things about environmental variables , but I have already set my classpath and path.

MIGHT BE IMPORTANT : I use Jdk 1.8.0_25

6
  • Maybe these links will help you stackoverflow.com/questions/18093928/… stackoverflow.com/questions/3005433/… Commented Nov 12, 2014 at 12:52
  • 1
    What does it mean "open java file". What are you exactly dowing? Commented Nov 12, 2014 at 12:52
  • Are you using the command 'java File.java' from the command prompt? does your File.java have a package declaration? Commented Nov 12, 2014 at 12:53
  • Should't you run .jar file, rather then .java? Commented Nov 12, 2014 at 13:20
  • by opening a java file I mean just double clicking a .java file. Commented Nov 12, 2014 at 13:35

1 Answer 1

0

.java files are not meant to be launched with java command.

You should compile it first with javac that will produce a .class file then if it's a class with a main method you can use java command.

Since you seem completely lost I would suggest reading at least the java documentation and do a welcome tutorial.

Note that if as you stated in your other question (which should be closed now) that you want to run a game server, just download already compiled classes not the sources.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.