How to access a class file outside the package?

created a two java files Counter.java and TestCounter.java as shown below:
public class Counter
     public void print()
          System.out.println("counter");
package foo;
public class TestCounter
     public static void main(String args[])
          Counter c = new Counter();
          c.print();
Both these files are stored under "D:\Test". I first compiled Counter.java and got Counter.class which resides in folder "D:\Test"
when i compile TestCounter.java i got the following error message:
D:\Test>javac -classpath "d:\Test" -d "d:\Test" TestCounter.java
TestCounter.java:6: cannot find symbol
symbol : class Counter
location: class foo.TestCounter
Counter c = new Counter();
^
TestCounter.java:6: cannot find symbol
symbol : class Counter
location: class foo.TestCounter
Counter c = new Counter();
^
2 errors
what could be the problem. Is it possible to access a class file outside the package?

ya that's fine..if we have two java files where both resides in the same package works fine or two java files which donot have a package statement also works fine. But my doubt is, i have a Counter.class which does not reside in a package and i have a TestCounter.class which resides in a package "foo", in such a scenario, how do i tell to the compiler that "Counter.class resides in such a path, please look at that and give me TestCounter.class". i cannot use import statement to import Counter.class in TestCounter.java because i donot have a package for Counter.java.

Similar Messages

  • Reaching the java file outside the package?

    Hi how can i reach the java(or class) files outside the packge(i mean one top folder)
    For example i have a java file in a folder named tech and i want to reach a java file in the folder named support which is under tech folder is something like that possible if it is how?

    Then tech should also be in a package.
    So it would be..
    package tech;
    import tech.support.*;and
    package tech.support;
    import tech.*;

  • How to import a class not in the package from a package

    how to import a class not in the package from a package?

    http://java.sun.com/docs/books/tutorial/java/interpack/usepkgs.html

  • How to run several class files at the same time

    I have four class files, there's: cvnt1.class,cvnt2.class,cvnt3.class and cvnt4.class.
    I want to know how to write application for running all of those files together. thanks!

    Your question is still unclear - do you want to access code from those class files (just add all of them to classpath) or do you want to create number of threads or number of processes (one per class) and start code from each class simultaneously or something else?

  • How to access  Schema(.xsd) file in the work flow

    Hi all,
    Please help me.
    regards,
    Jeevan

    Yes. You have to understand that to read a FILE (one that is seen as a file by your OS), you probably use a FileInputStream, which is a special case of InputStream. When the 'file' is not a FILE anymore, but an entry in a jar (the OS does not see it, only utilities like WinZip or jar see it), you cannot use a FileInputStream, but some other InputStream. Which one? The one returned by getResourceAsStream(), whatever this is (you don't really care). And all the rest will nicely fall into place.

  • How To Access a jar file present outside the war file through a jnlp

    Aoa
    I m new to this forum
    I m having problem with my jnlp file
    i want to know is there any way to access a jar file through jnlp.The problem is that my jnlp file is present in the war file
    and i want to know how to acess a jar file through this jnlp.The scenerio is as below
    I m using ear file on jboss.Its hirerchy is as
    -PAN-war.war
    -launch.jnlp
    -PAN-app-client.jar
    my jnlp file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://localhost:8080/" href="PAN/launch.jnlp">
    <information>
    <title>PanEmirates</title>
    <vendor>M Fazal Ur Rehman</vendor>
    <description>PanEmirates</description>
    <description kind="short">PanEmirates</description>
    <homepage href=""/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.5+"/>
    <jar href="PAN-app-client.jar" download="eager"/>
    <jar href="lib/javafxrt.jar" main="true" download="eager" />
    <jar href="lib/Filters.jar" download="eager"/>
    <jar href="lib/javafx-netbeans-fxuserlib.jar" download="eager"/>
    <jar href="lib/swing-layout-1.0.3.jar" download="eager"/>
    </resources>
    <application-desc main-class="net.java.javafx.FXShell">
    <argument>pan.Main</argument>
    </application-desc>
    </jnlp>
    when i run launch.jnlp file it says unable to download resource http://localhost:8080/PAN/PAN-app-client.jar
    how to access this jar file
    Any help or comment would be highly appreciated
    Regards
    M Fazal Ur Rehman

    Excellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
    Write another EAR file with the following structure:
    ear:
    META-INF/application.xml
    util.jar
    client.jar
    client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.
    Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.
    If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
    Points to note are:
    you have to repackage util.jar again inside this ear file.
    For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.
    Hope this helps,
    Sahoo

  • How can I restrict access to cloud storage from Creative Cloud? We don't want our users putting files outside the organization.

    We need to restrict our users from storing files outside the organization. How can we restrict this capability?

    They have Cs6, however I need to have my own copy, and the highest I can go with my system is CS5, maybe even 5.5. I've a small budget, and most copies are being sold for massive amounts because they're like collector items. I've seen the ones actually affordable within my range from sellers that arent trustworthy, or they're updates which I can't use. I had Cs2, but with updates to operating systems they stopped working. Thank you for your kind assistance.

  • Accessing files outside the jar

    Greetings,
    I've got a jar file with some classes, which is in a directory. In this dir there are also some resources. How to access those resources from inside the jar?
    Thanks in advance,
    imaginner

    Try this...
    In your class, add this line...
    String path = System.getProperty("user.dir");
    it will give the path of the folder from which you are running
    your jar file. To this path, add your properties file name
    and start reading it.....
    For example:
    If i have a properties file which both :
    1) should be able to read and edit by users and
    2) should be accessible by classes in jar file....
    I would use the above concept like this.... in my class.....
    String path = System.getProperty("user.dir");
    Properties props = new Properties();
    props.load(new FileInputStream(path+"yourPropertiesFileName"));
    Hope it helps...
    Vijay

  • Accessing files outside the root of the site.

    Hi All
    On my web host space I have access to a directory outside the
    root of the
    website i.e. "private"
    I want to store files there for download after users have
    purchased them.
    I want to put them here to stop people ripping the files off
    by guessing the
    link or useing a website copier.
    What I plan to do is send a link to the user via email, this
    link will then
    go to a download page which records the user has accessed the
    file and then
    have the page automatically download the file.
    I can do this no problem if I have the files in a directory
    under the root
    of the site but how can I link to the files outside the root?
    TIA
    Bren
    Why do I climb mountains? Simple! because they are there
    www.3peakschallenge.co.uk

    Sorry forgot to mention I am using ASP VB
    Cheers
    Bren
    "Bren" <[email protected]> wrote in message
    news:ejgd9n$427$[email protected]..
    > Hi All
    >
    > On my web host space I have access to a directory
    outside the root of the
    > website i.e. "private"
    > I want to store files there for download after users
    have purchased them.
    > I want to put them here to stop people ripping the files
    off by guessing
    > the link or useing a website copier.
    > What I plan to do is send a link to the user via email,
    this link will
    > then go to a download page which records the user has
    accessed the file
    > and then have the page automatically download the file.
    > I can do this no problem if I have the files in a
    directory under the root
    > of the site but how can I link to the files outside the
    root?
    >
    > TIA
    > Bren
    > --
    > Why do I climb mountains? Simple! because they are there
    > www.3peakschallenge.co.uk
    >

  • How can I access a response file on the same computer but with different login?

    When trying to access a response file on the same computer that was used to set it up, but with a different login, I get an error message that the network resource was not found. How can I retrieve the responses on the same computer but under a different login/username?

    The response file is associated with a specific login (as determined under Edit > Preferences > Identity) so you cannot retrieve it if you're using a different login.

  • How to add class file to the project in netbean

    Hi,
    I am not sure if it is the right place to put the question. I just cannot find the way to add my existing java class file into the project in net bean.
    Anyone can help?
    Thanks a lot

    Look at the "classpath" entry on the Index tab in NB's Help. There are entries there that explain how to add existing classes and libraries to a project.

  • How can I run a a class file on the Apache server?

    Hi Guys and Gurus,
    I am seeking some favor all of experienced gurus, i.e.
    How can I run a a class file on the Apache server?
    Actually, I want to extract some records from a MySQL Database running on Apache Server. I wrote a program just to select the columns and show them. It is now a Class file, Now how can I run this class file from the Server???
    Please advise...
    VJ

    cross posted
    http://forum.java.sun.com/thread.jsp?thread=299137&forum=31&message=1184025

  • URGENT PLEASE:How can I run a a class file on the Apache server?

    Hi Guys and Gurus,
    I am seeking some favor all of experienced gurus, i.e.
    How can I run a a class file on the Apache server? Can I run through an Applet?
    How can I set Environment variables in Windows2000 Professional Environment?
    Actually, I want to extract some records from a MySQL Database running on Apache Server. I wrote a program just to select the columns and show them. It is now a Class file, Now how can I run this class file from the Server???
    The code is here
    import java.sql.*;
    public class RecordShow {
    public static void main(String args[]) {
    String url = "jdbc:mysql://localhost/myhost";
    Connection con;
    String query = "select mytable.column," +
    "from mytable " +
    "where mytable.column = 1";
    Statement stmt;
    try {
    Class.forName("com.mysql.jdbc.Driver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try {
    con = DriverManager.getConnection(url,
    "myuser", "mypassword");
    stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(query);
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    int rowCount = 1;
    while (rs.next()) {
    System.out.println("Row " + rowCount + ": ");
    for (int i = 1; i <= numberOfColumns; i++) {
    System.out.print(" Column " + i + ": ");
    System.out.println(rs.getString(i));
    System.out.println("");
    rowCount++;
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.print("SQLException: ");
    System.err.println(ex.getMessage());
    Please advise... THANKS
    VJ

    Ehm, I wasn't referring to you at all... read up,
    there's a comment by jschell saying that CGI might be
    easier/better for his purposes.
    Yep.
    I know PHP/Perl/whatever might be easier for some
    purposes, but only if you happen to know them and want
    to/are able to use them. Ok. But you aren't the one asking the question are you. And the person who asked the question seems to have absolutely no familiarity with Apache or applets.
    So whatever they do they are going to have to learn a lot.
    And that does indeed suggest that in all likelyhood they have not investigated the alternatives.
    And for the vast majority of internet applications, especially with smaller projects (obvious this person is not working with a large team), using perl, or something besides java, is going to be the best business solution. It is simpler, and more secure (probably due to the fact that it is simpler.)
    Since this is a Java forum, I
    answer under the assumption that people have made a
    choice one way or another to use a Java solution to
    their problem, so I try to solve it in Java first, and
    only when that fails (very seldom) do I turn to other
    solutions.You approach problems by arbritrarily deciding to try to solve it in java first and only if you fail do you then look to other solutions?
    My first step is to try to figure out which of the various avenues is going to cost less. (And a secondary, but non-trivial concern, is then to convince the customer that just because they have heard of a buzz word like 'enterprise bean' that it doesn't mean that is a cost effective solution.) We must come from different worlds.

  • How to attach a PDF file TO the form so that recipients can access the file as a resource?

    How to attach a PDF file TO the form so that recipients can access the file as a resource?

    Sorry we do not support this. What you can do though is add a Formatted Text element and add a link to a PDF. To insert a link add some text, select the text and right click on the text (or look under the Insert menu in the top right of the scene)
    Gen

  • How to find the location of controller class file on the server

    Hi OAF Experts,
    We have a extended controller in which we are making some changes. We have compiled the java file.
    Now we want to deploy the .class file on the server. When we search on the server where we need to deploy the class file, we find two to three paths. Is there a way from which we can decide which path is actually referred ?
    Is there a front end page available from where we will be gettng these details??
    Regards
    Samarth

    Hi,
    You can get the complete path from front end.
    On 'About this Page', there is a section for 'Business Components'. When you expand that, you can see all the controllers used with complete path.
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • QuickTime 6 MPEG-2 Playback Component on QT 7.5 problems- will not work

    I am running QT Pro 7.5 (it is registered) on os/x 10.5.4 (Intel). The mpeg-2 component does not seem to work after it is installed & the system reboots. I get a box saying "this is not a movie file"...yet freeware mpeg-2 converter Handbrake sees and

  • Dropped frames or out-of-sync audio

    Using Sony HDR-FX1 and FCE-HD is set to DV-NTSC. I've also tried DV-NTSC Firewire Basic. I've been trying various suggestions I've found in the Discussions to cure dropped frames that prevent me from capturing and out-of-sync audio making footage I d

  • How to disable CHARGES tab in Find Sevice Requests(CSXSRISR.fmb / CSXSRISV)

    could any one please let me know how to disable CHARGES tab in Find Sevice Requests ( CSXSRISR.fmb, but funtion registered is CSXSRISV). Actually when i access the "Create Service Requests" menu option, the form comes up with a the three TABS (Charge

  • KEYNOTE DIFFERENCES BETWEEN A CATALYST LAN SWITCH & A STORAGE SWITCH (MDS)

    Hi Guys, I had a very simple query. I had a very basic query. I wanted to know the difference between a switch which we connect to our campus netorks and switches connected to storage area networks. I dont mean the cost and stuff, but more into how t

  • Standard Preview versus 1:1 preview

    I've always been curious about the differences between these two previews. Given the fact that Import can optionally generate a standard preview, why would I want a 1:1 preview? And if 1:1 is preferable should a standard preview not be performed duri