How can  I access my java class file in a .jar file ...PLz Help anyone!!

Hi Folks,
I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program.
Plz help ...I have tried all I know in vain.
Thanks.

temba wrote:
Hi Folks,
I am new in Java programming, have a .jar file that contains .java files that I want no access and use from another .java file. These files in the .jar file basically form a library thus have no main-method. However I can not declare an instance of the library (in the .jar file) and use it within my program. You are making little sense. You can't instantiate .java files.
Plz help ...I have tried all I know in vain.
Thanks.Could you post WHAT you have tried and also post what error messages you received?

Similar Messages

  • How can i run a java class file from shell?

    Hi all,
    I've a .class file named "File" that contains Main method, it is in the package "File2".
    How can I run it by shell command?
    PS: "java -cp . file" doesn't work it launch->
    Exception in thread "main" java.lang.NoClassDefFoundError: File2/File (wrong name: File2/File)
    Thanks in advance.

    Just to understand: is File2 ar jar archive or not? If it is a jar archive, have you tried open File2.jar? If File2 is a directory within the current directory, have you tried java -cp . File2/File? I just tested with a set of classes and it works... Let me be precise:
    * Let us imagine you are working in a directory whole path is PathToDir/
    * in this directory you have the classes put in a directory called File2
    * in order to launch File.class then you would have to invoke :
    cd PathToDir/ (just to be sure)
    java -cp . File2/File
    *if you were to do the following then you would have the problem you describe
    cd PathToDir/File2/
    java -cp . File

  • How can I share a *.java source file across multiple projects in NetBeans?

    I'm sure this simple and a pretty common operation but how can I share a *.java source file across multiple projects in NetBeans? Right now I keep cut, coping and pasting the same source file between multiple projects to re-use the same code. But I could I make this source file a library file or something like that so that I could access it from any project. I assume this would be a generic operation but I mentioned NetBeans for clarity. Thanks.

    fiebigc wrote:
    I know I mentioned NetBeans but I'm most interested in the generic method for creating a library of source files that I can call into whatever program I am developing. I've done such a thing in C using header files and such but I'm trying to get a direction on how this is accomplished in Java. I'm sorry if I could edit the title I would. If anyone wants to be specific about NetBeans I welcome that too.
    Edited by: fiebigc on Jun 20, 2008 5:57 PM
    >I know I mentioned NetBeans but I'm most interested in the generic method for creating a library of source files that I can call into whatever program I am developing. I've done such a thing in C using header files and such but I'm trying to get a direction on how this is accomplished in Java. I'm sorry if I could edit the title I would. If anyone wants to be specific about NetBeans I welcome that too.
    Edited by: fiebigc on Jun 20, 2008 5:57 PM
    Create a class library.
    Write your code, compile it to .class files, put those class files in a .jar file and include the jar file in the classpath whenever you want to compile a project against it.

  • 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 can I access my iCloud Drive files on my iPad?

    I have many Preview (PDF) files stored in iCloud Drive. How can I access them on my iPad?
    REgards,
    Gregory

    Use Safari to access www.icloud.com (you must Request Desktop Site)
    You will be able to access iCloud Drive ( see picture below)

  • How can I rewrite the java.io.file class to a custom file class?

    Hi All!
    Im new to Java. Well, I did some experiments with small Applets. Because it is not allowed to use Files in an unsigned Applet, I need to know, how I can manage to overwrite the java.io.File class. The background: I have to port some Applications which need file access into Applets.
    I think it is necessary to create a class with the same signature then the Java.io.File that stores the information in an database on the Webserver or read information from there. Then overload the java.io.File with my custom file class.
    Is this possible and, if so, how?
    Thanks!

    Hi yawmark !
    Thanks for the quick answer! My idea to store the filecontent into a database is caused by the plan to make the application-port independent from the workstation executing it. So it would be a nice feature storing the "files" into a database.
    JavaBeginner2009

  • How can I call a java class from within my program?

    I was wondering if there's a platform independent way to call a java class from my program.

    Here's my scenario. I'm working on a platform independent, feature rich, object-oriented command prompt program. The way I'm designing it is that users can drop classes they write into my bin directory and gain access to the class through my program. For example, they drop a class named Network.class in the bin directory. They would type Network network at my command prompt and gain access to all the methods available in that class. They can then type system.echo network.ipaddress() at my prompt and get the system's ip address. I have it designed that there's a server running in the background and the clients connect to my port. Once connected the end-user can enter their user name and password and gain access to the system. When they type a command they actually call another java program which connects to my server using a seperate thread. They can then communicate back and forth. I have it set that everything has a process id and it's used to keep track of who called what program. Once the program is done it disconnects and closes. Rather than getting into the nitty gritty (I didn't want to get into heavy detail, I know how everything will work) I'm really interested in finding out how I can call a java program from my program. I don't want it to be part of the app in any way.

  • How can I execute a java class with arguments from an air application built from mxml?

    I have an mxml application. It has a button, and when that button select event occurs, I want my mxml air app to pass arguments to a java class I have built, which resides in a package path on my system. I need to be able to pass several arguments to my java method from my mxml call. How do I do this, and what config files are necessary? For the simple task I want to engineer, can you show me an example of a properly configured config file? My java class has been executed at the command line in the past as follows:
    java -cp %CP% com.abc.prism.queue.EmitMessage XYZ "my message text" 192.12.13.14 5672
    where %CP% is an env variable that tells my class the classpath it runs with, and XYZ, "my message text", the IP address, and the port are the arguments I must pass from mxml to my java class. How do I accomplish this?
    How do I make known to the java class I call from mxml the %CP% class path? It tells my java class where to find various rabbitMQ jars.

    Hi,
    You need to use Integration technology like BlazeDS or LCDS.

  • How can i mention a java class in the form's action=" ...."  in jsp

    if i am not using struts frame work, how can i call?
    i am not using any of the frame work.
    for example.
    i am searching for a customer name from a database
    i have coded the form fields in jsp
    as
    <%@page session="true"%>
    <%@page errorPage="ErrorPage.jsp"%>
    <%@page import="com.krysl.model.*"%>
    <jsp:useBean id="model" scope="session" class="com.krysl.model.webmodel"/>
    <html>
    <head>
    <title>Customer Seach</title>
    <jsp:include page="SetBaseURL.jsp" flush="false"/>
    <link rel="stylesheet" href="http://forums.sureshkumar.net/style.css">
    </head>
    <body>
    <jsp:include page="Banner.jsp" flush="false"/>
    <h1>Customer Search</h1
    <form method="POST" action=".......................">
    <b>Customer Name</b>
    <input type="TEXT" name="customerSearchArgument" size="20">
    <input type="submit" value="search">
    </form>
    </body>
    </html>
    this "customerSearchArgument" will receive a class method
    package com.krysl.controller;
    import java.io.*;
    import java.sql.SQLException;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import com.krysl.model.*;
    * @author dsdc
    public class customersearchaction extends Action
    public void run() throws ServletException, IOException
    String arg = request.getParameter("customerSearchArgument");
    if(arg != null)
    arg = arg.trim();
    if(!arg.equals(""))
    try
    model.customerSearch(arg);
    catch(SQLException e)
    throw new ServletException(e.getMessage());
    final String next = "/CustomersList.jsp";
    RequestDispatcher rd = application.getRequestDispatcher(next);
    if(rd == null)
    throw new ServletException("Could not find" + next);
    rd.forward(request, response);
    All other database connections and related things i coded in
    some other classes webmodel, model, controller servlets etc....
    in the above class the model.customerseach(arg);
    will do all the searching.
    my doubt is how to call this method in that action="" of jsp
    i tried as action="com.krysl.model.customersearch"
    action="com/krysl/model/customersearch"
    its not working
    please letme kno
    urget
    thank you

    Hi.
    go to otn.oracle.com/products/forms and get infromation about PJC and JavaBeans in Forms. The keyfilter example is available as sample as well. However, the link temporarily doesn't work
    All Forms demos and code sources: http://download.oracle.com/otndocs/demos/Forms_Demos_10gr2.zip
    Frank

  • How to find the main java class file

    I need to write a Java program which MUST know one of these:
    1) the full path to the main java class (the class with "main" method)
    or
    2) access to the main class as byte array.
    If i know (1) then I have no problems reading the main class into byte array, but the main target is still (2).
    Another option is if the main file is in JAR, which again leads to problems, because I cannot access the file in normal way, but I still need access to the exact byte stream.
    Any help is highly appreciated! Thanks!
    <<< Ivan Davidov >>>

    You could try somthing like this in your main-method:
    InputStream is = getClass().getResourceAsStream(<"myModifiedPackageName/MyClass.class">);I don't know if this works though.
    Have a look at the API doc for this method.
    -Puce

  • HOW CAN I ACCESS MY IPODS MP3 FILES

    i deleted my music folder by mistake and now only have all my mp3's on my ipod, how do i get them off my ipod to a new music folder ...please can anyone help me ?

    There is a manual method of accessing the iPod's hard drive and copying songs back to iTunes on Windows posted in this thread: MacMuse - iPod to iTunes
    If you prefer something more automated then there are a number of third party utilities that you can use to retrieve the music files and playlists from your iPod, this is just a selection. Have a look at the web pages and documentation for these, they are generally quite straightforward. As iTunes 7 is just out some of these may not have caught up with it yet though I haven't experienced any problems with the Mac software I use.
    YamiPod Mac and Windows Versions
    iGadget Windows Only
    iPodCopy Mac and Windows Versions
    iPod Access Mac and Windows Versions
    PodUtil Mac and Windows Versions
    iPodCopy Mac and Windows Versions
    PodPlayer Windows Only
    CopyPod Windows Only
    There is a new function in iTunes 7 under File, "Transfer Purchases from iPod" which transfers iTMS purchases. A paragraph on it has been added to this article: How to use your iPod to move your music to a new computer
    If your iPod is set to update automatically take care when connecting back to your computer and an empty iTunes. If it is set to automatically update you will get a message that your iPod is linked to a different library and asking if you want to link to this one and replace all your songs etc, press *No* (or "Cancel" if you are using iTunes 7). Pressing "Yes" (or Erase and Sync in iTunes 7) will irretrievably remove all songs from your iPod. Your iPod should appear in the iTunes source list from where you can change the update setting to manual and use your iPod without the risk of accidentally erasing it. In iTunes 7 Check the "manually manage music and videos" box in Summary then press the Apply button. Don't uncheck Sync Music it will be unchecked by default when you choose the manual setting: Managing content manually on iPod
    You can also use a keyboard command to prevent your iPod auto-syncing with iTunes. While connecting the iPod to the computer on Windows hold down the Shift + Ctrl keys (on a Mac hold down the Option and Command (⌥ and ⌘) keys). This will stop the iPod from auto-syncing with iTunes and the iPod will appear in the source list. Wait until you are sure the iPod has mounted, and that it will not auto sync and then you can let the keys go. This may take between 20 to 30 seconds depending on your computer.
    Whichever of these retrieval methods you choose, keep your iPod in manual mode until you have reloaded your iTunes and you are happy with your playlists etc then it will be safe to return it auto-sync again. I would also advise that you get yourself an external hard drive and back your stuff up in case you have problems again. External drives are comparatively inexpensive these days and you can get loads of storage for quite a small outlay.

  • How can I load my java class dynamically ???

    Hi guyz !
    Please look on my problem:
    1. I write code under Windows.
    2. I have file testcls1.java with class by name 'TestCls1'. /package 'hs0'/
    3. I try to use method Class.forName.
    4. File on disk is "c:/shttpsrv0/SrvFiles/java/testcls1.java".
    5. I get exception ClassNotFound.
    Question: what is right way to write first parameter for method ???
    Thanx in advance !

    Hi guyz !
    Please look on my problem:
    1. I write code under Windows.
    2. I have file testcls1.java with class by name
    'TestCls1'. /package 'hs0'/
    3. I try to use method Class.forName.
    4. File on disk is
    "c:/shttpsrv0/SrvFiles/java/testcls1.java".
    5. I get exception ClassNotFound.
    Question: what is right way to write first parameter
    for method ???Class.forName can use *.class files only. If you have *.java file, you have to compile it first. Moreover, Class.forName uses CLASSPATH. If you want to provide the exact location of *.class file, try to use URLClassLoader.

  • How can I access old back up files?

    I have a seagate back up drive where I pointed time machine to back up my files. I recently replaced my hard drive and was told I would be able to access the back up files to restore any old data I may want. I see the back ups but they are in a darker purple. I only have access to back ups on the external drive I have created since having the replacement drive installed. What is the purpose of backing up data if you can not get to it with another hard drive or computer?
    Why is an easy concept such a difficult procedure. Once I point it to the old back ups it should not only see them, but be able to access them.
    I have the old drive and other pages referred me to Backups.backedupd to manually get to the back up files. I can search and find backups but there is no folder backedupd. I also cannot find a complete name of the above. It is frustrating not to be able to find an answer to a fairly common question.
    Thank You

    Was it made using Mountain Lion?
    As nice as TimeMachine is now, it wasn't always – it will be 6 yrs since intro'd in 10.5 –
    This is what will probably work
    http://www.tri-edre.com/english/backintime.html
    Obviously you don't want to make the old drive as active backup destination, but I have two TM drives, both connected (I switch between them for daily, weekly and such) and both show up as standard TM "green" icon on my desktop.
    This is a good FAQ
    http://pondini.org/TM/Home.html

  • How can we call one java class in another java class?

    Hi all,
    My problem is ,
    one java code creates a file i have to send that file through email as an attachment here i wrote a java code to send a mail with attachment
    can any one help me how i can implement this. my idea is to write a send mail function in 1st java code which creates the file
    Is this a better idea ???plz suggest me.

    Hi all,
    My problem is ,
    one java code creates a file i have to send that file
    through email as an attachment here i wrote a java
    code to send a mail with attachment
    can any one help me how i can implement this. my idea
    is to write a send mail function in 1st java code
    which creates the file
    Is this a better idea ???plz suggest me.may samaaj nahi atay

Maybe you are looking for