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?

5 Answers 5

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.

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

2 Comments

This would give Error: Could not find or load main class classname.class. '.class' should not be the part of that command ;)
@mtk oupssss Fixed ;-) To long since I manually entered a java command ;-)
2

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

Comments

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.

Comments

0

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

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.