• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Devaka Cooray
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • Henry Wong
  • paul wheaton
  • Ernest Friedman-Hill
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Mikalai Zaikin

Howto Import Class

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im using Eclipse, and I want to import StdDraw.java
how to do that
I tries
import StdDraw
import StdDraw.java
import StdDraw.class

all are not working, how to import the class?
 
author
Posts: 23949
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sam Benry:
Im using Eclipse, and I want to import StdDraw.java
how to do that
I tries
import StdDraw
import StdDraw.java
import StdDraw.class

all are not working, how to import the class?



You need to specify the class, not the file where the class is in.

Open the file, and note the package that the StdDraw class is in. Let's say that it's in some.package, then import via...

import some.package.StdDraw;

Just change some.package to the actual package that StdDraw is in.

Henry
 
Henry Wong
author
Posts: 23949
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A couple more points....

First, with Eclipse it is easier than that -- you don't need to open the file. Eclipse will list the package that the java file is in via the package explorer.

Second, if the class that you want to import is in a different project, don't forget to have your project refer to the other project.

Henry
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic