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?

Rohit
  • 8,548
  • 23
  • 63
  • 103

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
  • 17,796
  • 21
  • 83
  • 129
  • 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
  • 837,282
  • 173
  • 1,862
  • 1,933
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,624
  • 9
  • 58
  • 94
0

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

mtk
  • 12,450
  • 15
  • 69
  • 109
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