0

I am taking a course on Coursera and as part of a quiz I am supposed to download their xyz.class and run it. I want to do it in eclipse as all of jar files are added in eclipse and I dont want to modify the class path of system as it is very untidy.

But I dont know how to run a external .class file through?Can anyone help me with that?

Max
  • 9,100
  • 25
  • 72
  • 109

5 Answers5

3

Why do you want to run it in Eclipse ?

java classname

souhld do the trick. You can't use Eclipse to run an external class file with a main method without creatin a java project with this class in its class path.

Manuel Selva
  • 18,554
  • 22
  • 89
  • 134
  • This would give `Error: Could not find or load main class classname.class`. '.class' should not be the part of that command ;) – mtk Aug 12 '12 at 19:34
  • @mtk oupssss Fixed ;-) To long since I manually entered a java command ;-) – Manuel Selva Aug 12 '12 at 19:35
2

Right-click your Eclipse project, Build Path, Configure Build Path, Libraries, Add (External?) Class Folder.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

Just run

java xyz

eclipse might not required.

If you want to really work out through the eclipse then refer How do I include .class files in my project in Eclipse? (Java) answer.

There is another way of approach without using eclipse.

Approach is by creating a executable jar file and by including all required libraries & xyz.class.

Community
  • 1
  • 1
Siva Charan
  • 17,940
  • 9
  • 60
  • 95
0

Right click on the class file from the Package Explorer -> Run.

mtk
  • 13,221
  • 16
  • 72
  • 112
0

goto file >> new project >> Import>> add executable jar files >> select your path where you have stored your .class files>> check include in work place

apply>> ok >>>>>>>>>>>>>>>>>>>>Done

gautam
  • 1
  • 1