Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How to make a project with a main in a .class file?
How to make a project with a main in a .class file? [message #984652] Wed, 14 November 2012 16:50 Go to next message
d grin is currently offline d grin
Messages: 12
Registered: June 2012
Junior Member
I have a project for school in which the professor has given me sos.class which contains a main function. No source to that file has been given. I need to write my own java file that works with it. How do I make an eclipse project that will be able to run the main in the .class file? Thanks.

Edit: I would also prefer that the class and source file be in the same file.

[Updated on: Wed, 14 November 2012 16:57]

Report message to a moderator

Re: How to make a project with a main in a .class file? [message #985514 is a reply to message #984652] Thu, 15 November 2012 08:02 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
On 14.11.2012 22:50, d grin wrote:
> I have a project for school in which the professor has given me
> sos.class which contains a main function. No source to that file has
> been given. I need to write my own java file that works with it. How
> do I make an eclipse project that will be able to run the main in the
> .class file? Thanks.

Create a Java project, then add a folder and put it on the Java build
path (as Class Folder). You can then add the class file into that folder
and run it.

Dani
Re: How to make a project with a main in a .class file? [message #985656 is a reply to message #985514] Thu, 15 November 2012 10:52 Go to previous messageGo to next message
d grin is currently offline d grin
Messages: 12
Registered: June 2012
Junior Member
How do I add a folder to the java build path?
Re: How to make a project with a main in a .class file? [message #985663 is a reply to message #985656] Thu, 15 November 2012 11:09 Go to previous messageGo to next message
Russell Bateman is currently offline Russell Bateman
Messages: 3148
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 11/15/2012 8:52 AM, d grin wrote:
> How do I add a folder to the java build path?

Assuming you already have a Java project, just create a new folder
underneath the one (already there) named src.
Re: How to make a project with a main in a .class file? [message #985673 is a reply to message #985663] Thu, 15 November 2012 11:24 Go to previous messageGo to next message
d grin is currently offline d grin
Messages: 12
Registered: June 2012
Junior Member
I added the folder to the build path using this guide - http://pic.dhe.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-112.htm

So now my java file sees the .class files. However when I try to run it eclipse says 'selection does not contain a main type.' I know for a fact that sos.class has a main since it works from command line. How do I get eclipse to search for main in the sos.class file?
Re: How to make a project with a main in a .class file? [message #986710 is a reply to message #985673] Wed, 21 November 2012 06:59 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
On 15.11.2012 17:24, d grin wrote:
> I added the folder to the build path using this guide -
> http://pic.dhe.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-112.htm
>
> So now my java file sees the .class files. However when I try to run
> it eclipse says 'selection does not contain a main type.' I know for a
> fact that sos.class has a main since it works from command line. How
> do I get eclipse to search for main in the sos.class file?
Make sure that the sos.class is selected when you launch.

Dani
Re: How to make a project with a main in a .class file? [message #987174 is a reply to message #986710] Fri, 23 November 2012 21:39 Go to previous message
d grin is currently offline d grin
Messages: 12
Registered: June 2012
Junior Member
That wasnt it. I had to make a custom run config and set sos as the main class. Now it all seems to work.
Previous Topic:How to open eclipse project on a different computer
Next Topic:workspace
Goto Forum:
  


Current Time: Sat Aug 23 09:33:47 EDT 2014

Powered by FUDForum. Page generated in 0.03465 seconds