This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line!
See this thread for details.
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

How copy to Java code onto Eclipse and make it work?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused as to how copy code for a game, Connect 4, onto Eclipse and make it work.
The problem is I am not sure whether to create a new 'Package' and paste the code there or make a 'Class' and paste it there or whether it's a combination of both.

Or maybe I need an interface....

Here is the code:

package Default;

 
Marshal
Posts: 68014
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I would suggest on Eclipse, you create a Project, then a package, then a class inside that package. You can copy and paste lots in to Eclipse; you can even copy an entire .java file into the right part of the workspace folder and Eclipse will recognise it as a class. It will show up errors like wrong package name, and allow you to correct them.
I would suggest you create a more object‑oriented version of that code, however.

Also package names should start with small letters. In which case Default will turn into a keyword, and the code won't compile. Try a different package name.
 
Campbell Ritchie
Marshal
Posts: 68014
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for noticing. I think if you follow the corssposting links you will find that question everywhere on the net
PO: please read this.
 
Ranch Hand
Posts: 38
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your class is java class you can directly paste after creating project and package using eclipse. Eclipse has very good features of automatically correct the errors however it may ask the classes your file requires in class path.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!