Organizing class files (in the filesystem)

Hi, I'm new to Java and the JDC. I have run into one issue, in my explorations in Java, and that is organizing the class files and source code files. I understand that I can organize them in any way that I like, but I was curious if there is a standard system that other Java developers use (like the /usr/local convention on Unix).
Should I create a /usr/local/java directory and then store class and source files in subdirectories of that? And then add the class directory to the CLASSPATH? How about downloaded source code that I didn't write -- that seems like it would then go in yet another directory.
So far I've got everything stored in ~/dev/java (a directory I created for this purpose), but it seems like it's bound to get unmanageable if I don't order it better. And I'm just curious what others with more experience do.
Thanks!
Erik

Anyway, back to why. If as you mentioned you keep all of your class files off a given root folder, then you can add that folder root to the classpath.
Okay, I have the domain "erikprice.com". So then I would create a hierarchy like this (?) :
- ~
  - dev
    - Java
      - com
        - erikprice
          - packageA
          - packageB
          - packageC
             ...etc...And then, if I add ~/dev/Java/com to my CLASSPATH, all of the classes in the various packages below that will be accessible to the compiler? Or do I have to explicitly put ~/dev/Java/com/erikprice into the classpath?
Also, if I have downloaded someone else's source code (such as a Jakarta project or something), it seems like I should put its root folder in with my personal root folder. In other words, like this:
- ~
  - dev
    - Java
      - com
        - erikprice
      - org
        - apache
          - xml
            - xerces
              - packageA
              - packageB
            - xalan
              - packageA
              - packageB
              ...etc...Does this seem right? If I understand correctly, I will have to add the org directory to the CLASSPATH too. Can I save all of this trouble by putting just ~/dev/Java into the CLASSPATH so that all of the packages below (com/erikprice/*, org/apache/xml/*, org/someotherproject/*) are available?
The trick of this is that I'm trying to organize both my own Java files as well as those that I've downloaded to study from. Thanks for your input, MLangstaff.

Similar Messages

  • Delete file from the filesystem?

    Hello,
    I have an easy question. But I don´t find the right oracle packages.
    I want to delete a file from the filesystem. How can I do this?
    Thanks for your help!

    Paul,
    If connecting to the Web server on East-Coast USA is not optimal for you, or if you aren't using Oracle 10g Release 2, try this URL instead:
    http://www.oracle.com/technology/documentation/index.html
    You need to look for the PL/SQL Packages and Types Reference document, the section detailing the UTL_FILE package.
    Good Luck,
    Avi.
    Message was edited by:
    Avi Abrami

  • Deleting files from the filesystem

    How can you delete a file from the filesystem in Java? Is it possible?
    Thanks

    File file = new File("c:\\test\\abc.txt");
    file.delete();

  • 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

  • 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.

  • 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 write files to the filesystem with portal/plsql

    Hi,
    is there a way to write files to the filesystem via Portal?
    Or can i call an external programm (perl, php) to do so, while portal writes further information to database?
    thank you for the help
    Ralf Schmitt

    Hi Ralf,
    my primary task is to publish download-links to files stored ... somewhere as a linklist. I tried to store and download files to/from the database but i cant get it to run. Upload works, download doesn't.
    (i'm not talking about a single form-query-download-link! I need a report-like linklist)If you want to do this you'll have to write some code but sure it's possible - i did it myself.
    The links in the link list in your report should call a stored function retrieving the files from Wwdoc_document or whatever is the document table defined in your DAD. Simply select BLOB_CONTENT into a BLOB variable from the table, provided you know what file to read :-) The function would then read the BLOBs and send them to the client's browser via DBMS_LOB - it's poor design but it works just as smooth as it could and it's really performing. This would simply display the file into your browser or prompt for file save location, depending on what browser you are using and its client settings.
    I guess this is not so clear, if you want some more details feel free to e-mail me at [email protected]
    Another way would be to use wpg_docload to both download and upload files to/from the DB.
    Now i try to figure out if it is possible to store the files to the filesystem and write only additional info like description or path into db.Again, yes, it is. I can't recall exactly how I did it ^_^ but the trick is to create a virtual directory in the DB - pointing at a physical directory on the file system you want to write to, and you have to have full read-write permission on the directory itself, and its path must be included in the utl_file_dir database parameter. Then you use both COM Automation or UTL_FILE to write files.
    would it be possible to let a portal-form write info to the db and then pass the file to a php-script?
    regards,
    Ralf Schmitt

  • Creation of class files on the spot

    I have read in an article that a class loader (generally a subclass of the abstract class ClassLoader can load classes from the local disk, fetch them across a net using a protocol, or it can just create the byte code on the spot.
    How can a class loader create files on the spot? Or, better: why would a class loader create a class file on the spot?

    It's rare, here's an admittedly contrived example.
    You have a database table, and you'd like to create a collection of objects that mirrors the collection of rows in the table. So you collect all of the types and names of each column, and create a new Java class with getter/setter methods for these columns, along with the private member variables themselves. If this class followed the JavaBean style, you could manipulate these objects and use them dynamically using bean tools.

  • Running class files from the windows command line...

    Hello Everyone,
    My instructor showed us a way to run class files from the windows command line. However every time I try to run the class file from the command line using a command like: java CruiseHelper.class
    I get an error that states "Exception in thread "main" java.lang.NoClassDefFoundError: CruiseHelper/class"

    Hello Everyone,
    My instructor showed us a way to run class files from
    the windows command line. However every time I try
    to run the class file from the command line using a
    command like: java CruiseHelper.class
    I get an error that states "Exception in thread
    "main" java.lang.NoClassDefFoundError:
    CruiseHelper/class"Classes are not file names. You don't have a class named "CruiseHelper.class", that's a file name. The class name is just CruiseHelper (if you have no package statement in it).
    So,
    java -classpath . CruiseHelper

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Best practise, do you store your files in the Filesystem, too?

    I hope you can answer my question? For three weeks we have all the objects in the Repository &#0124; &#0124; and on the filesystem. We have mapped the repository to the filesystem.
    Does that makes sense? Or should we delete all the data from the filesystem so that we haven't stored it redundant?
    What would you prefer?
    AND: Is it possible to start a script e.g. for creating a table out of the script which lies in the repository?
    Or for DBA things would it be better to store the scripts outside again?
    Thank you very much
    Henrik

    You should use the local file system only when you need to edit the files. However, the Repository will warn you if the file system and the repository stored files become out of synch.
    Store all the scripts in the Repository.
    You could associate a .sql file with sqlplus. Thus on opening the file from the Repository sqlplus would be started and ask for a username/password.

  • Getting generated class files using the compiler api??

    I am writing a compiler/IDE for java, and i use the new JavaCompiler API
    (javax.tools.JavaCompiler)
    i want to ask, is it possible to get the generated class file(compiled file) names??
    can anyone help me with this, read at the documentation and i have no idea which one is used to do such thing..
    Or is it impossible??
    Thanks, please guide me on this..

    E.D.-inc wrote:
    I am writing a compiler/IDE for java, and i use the new JavaCompiler API
    don't.
    i want to ask, is it possible to get the generated class file(compiled file) names??
    yes, probably (after all, other tools can do it). Don't ask me how though, I've never had a need to.
    can anyone help me with this, read at the documentation and i have no idea which one is used to do such thing..
    no. Someone else reading the documentation for you won't help you any. Read it yourself, you might learn something.

  • Java .class files - Moving the Main Class .class file to a new location

    Novice question....so much so that I hope it's even coherent...
    In a Java program which references many associated .class files (e.g. bicycleMain.class, bicycleSub1.class, bicycleSub2.class, etc....), do the associated .class files always have to be located in the same directory as the Main .class file?
    What I'm getting at is - If I've developed an application consisting of several .class files on my own Windows PC and I want to put the compiled application out on our Windows File Server so that anyone can execute my application, how would I go about doing this?
    Say I put the compiled .class files in H:\PROJECTS\JAVA\COMPILED\, will other people be able to execute the application from their PCs by simply issuing the command line:
    'java h:\projects\java\compiled\bicycleMain'
    Any insights would be very helpful in getting me oriented. Thanks in advance.

    Interesting...so are you saying the command line might look something like this:
    java -classpath h:\projects\java\compiled bicycleMain
    And if I want other people to be able to execute the application without specifying the -classpath option then they would need to manually update the ClassPath environment variable on their individual PCs first?

  • Where to place the class file of the java bean when using the packager

    I am using the activex bridge in j2se 1.5.0_06
    now i have created the jar file for my bean but where do i place the class file?
    i.e the bean..if i keep it in jdk\bin the packager gives me an error..i created a folder in my public jre jre\axbridge\bin and placed the class file there too but even this didnt work
    Kindly tell me what is the fully qualified package bean name if i have placed all my files under jdk\bin..

    D:\Java\jdk1.5.0_06\bin>packager -reg d:\java\jdk1.5.0_06\bin\PersonBean.jar Per
    son
    Processing D:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\\Person.idl
    Person.idl
    Processing D:\PROGRA~1\MICROS~2\VC98\INCLUDE\oaidl.idl
    oaidl.idl
    Processing D:\PROGRA~1\MICROS~2\VC98\INCLUDE\objidl.idl
    objidl.idl
    Processing D:\PROGRA~1\MICROS~2\VC98\INCLUDE\unknwn.idl
    unknwn.idl
    Processing D:\PROGRA~1\MICROS~2\VC98\INCLUDE\wtypes.idl
    wtypes.idl
    Registration failed:
    The packaged JavaBean is not located under the directory <jre_home>\axbridge\bin
    this is the error i get

Maybe you are looking for

  • Arch box appears to knock out wifi

    I have encountered an interesting problem with my home network. My arch box has been out for a while and during that time I and all others in my apartment have had no issues with wireless connectivity. Recently however, I was able to get my desktop r

  • Sql queries for date and year

    Hi Friends, I Have a view named - item_sales with 4 column Item code Item name Transaction_YYYYMM (Date stored in YYYYMM format ) QTY_RECEIVED QTY_SOLD Sample data is ITEM_CODE ITEM NAME  TRANSACTION_YYYMM     QTY_RECD    QTY_SOLD AX             TSHI

  • Openzone Signal Repeating

    Currently working away from home and as luck would have it there is a weak Openzone signal down the road. If the atmospherics are good I can get onto this otherwise I need a signal repeater in one of my front windows. Question - will the signal repea

  • Employee Profile in Solution Manager - ITSM

    Dear, We are going to implement the Solution Manager- ITSM (Service Desk), in our company, they have a Contact Center where the employee can call through a specific number and request an assistance from the IT Helpdesk. Through the IVR the employee w

  • Convert package to function..

    can anyone convert this package to function so that we can use it in sql command.. {color:#993300}create or replace package metaphone is function generate(s varchar2) return varchar2; end metaphone; show errors;{color} {color:#993300}create or replac