A question for my jar file

When using the jar command, do I have to specify any imported classes that I have downloaded from the net to use in my main class?

Here's an example that works for me. I made a temporary directory c:\tempjava inside of which is the RabbitHole class that you posted. There is also c:\tempjava\TerminalIO directory that contains the KeyboardReader and ScreenWriter classes.
To create an executable jar that includes the TerminalIO classes:
1. I created a manifest file, c:\tempjava\Manifest.txt that looks like this.Manifest-Version: 1.0
Main-Class: RabbitHole2. I created a jar by using the commandjar -cvfm rh.jar Manifest.txt *.class TerminalIO\*.class3. I executed the jar usingjava -jar rh.jarTo create an executable jar that relies on the TerminalIO classes being in the c:\tempjava directory:
1. I created a manifest file, c:\tempjava\Manifest.txt that looks like this Manifest-Version: 1.0
Main-Class: RabbitHole
Class-Path: rh.jar  /c:/tempjava/2. I created a jar by using the commandjar -cvfm rh.jar Manifest.txt *.class3. I executed the jar usingjava -jar rh.jarIf you want to make the TerminaIO package relative to the jar file - that is, the jar expects the TerminalIO package exists in the same directory as the jar file - then modify the manifest by replacing /c:/tempjava/ with . (the current directory).

Similar Messages

  • Best practices for managing jar files

    just wondering what anyone's thoughts are on managing jar files. I have read that instead of adding the jar files to your CLASSPATH environment variable, you can just extend the jdk. This is accomplished by inserting the jar files into the C:\jdk1.3.1_01\jre\lib\ext directory. I suspect that if the latter option is truly feasible, it would be preferred to adding entries to the CLASSPATH variable for every jar file you want to use. You could end up with hundreds of entries into the CLASSPATH variable if you have that many jar files in use.
    Any thoughts, comments, or links to where I can find any info on this?...
    thanks for any information.....

    In my company, we use scripts (in UNIX system) to handle this problem. The following scripts can iterate jar files in a given directory:
    for i in ${YOUR_LIB_DIR}/*.jar
    do
    YOUR_CLASSPATH=${YOUR_CLASSPATH}:$i
    done
    With this simple script, you can use any directory in the same way as the ext\ direcotry (just copy the jar file in it), and you still have the flexibility of maintaining jar files in different directories, say a number of projects.
    but i don't know whether .bat/.cmd scripts for windows have the same function.

  • Looking for a JAR file...

    I am looking for the jar file that has the following in it:
    com.sapportals.portal.htmlb.page.JSPDynPage;
    com.sapportals.portal.htmlb.page.PageProcessorComponent;
    Can someone PLEASE PLEASE email it to me?
    My email address is [email protected] .
    Thank You?

    I do not have NWDS installed (that is a whole other issue).
    But someone did send me the file.
    Plus, I already had it but just did not know where to look. Now I know where to look.
    Thank you

  • Why tomcat is still looking for old jar files?

    Please help me it is a very serious problem.
    I updated one of the jar files used by the project. I am using a new method that is available only in the new library. I removed the old jar files in my local system, and everything worked fine. Then I commit those files to the subversion, which is in the testing server, and then I created the war file. The war is successfully created, then I deployed to the tomcat. But, now there is an error in the portion I am using the method that is only available in the new jar files.
    One of the error when I go to that portion is:
    1. No Such Method Exists
    The other errors on log files are:
    1.
    WARNING: Failed to open JAR
    java.util.zip.ZipException: No such file or directory
    2.
    validateJarFile(tomcat/webapps/ROOT/WEB-INF/lib/j2ee.jar) - jar not loaded. See Servlet Spe
    c 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    Please help me, I have tried every other way to solve this. I have tried removing all the old jar files there were, and replacing with the new one. I have tried creating a war file and ftping to the testing server.
    I problem is still there and it is because the testing server's tomcat is still looking for old jar files. I used Netbeans and add jar files as usual method.

    Check the contents of your WAR file that you are deploying on the testing server to see if it contains the JAR that you can't find.
    More than likely you are building your WAR file and your new JAR file is not being included in the build.

  • Three questions about signed jar file and applet

    I use three signed jar file. Each of them signed by different certificate. First of JARs contain applet class. When I start applet from html page I see message “This applet was signed by…… but Java cannot verify it… Do you trust…?”. All times I press “Yes I trust” and after this questions applet stop to work end exit. If I use only one certificate for signing of three JARs then applet continue to work after question. 1) What should I do to fix this bug? 2) Is it any method to check from applet that user press Trust button? Is it any method to emulate work of SecurityManager to check that Certificate object is trusted (I want do call some method check(Certificate) and if certificate is not trusted I want to see message with question: “Do you want to trust this certificate” and so on)?

    Hello Jarman,
    1. If I have a signed jar file, then as long as the
    certificate is recognised as trusted that applet can
    run as a fully trusted application on the client
    machine. So I should not have to add lines such as
    permission java.lang.RuntimePermission
    "readFileDescriptor", "read" ;
    permission java.lang.RuntimePermission
    "writeFileDescriptor", "write" ;
    to my java.policy file. true/false ?true
    2. If I am running a signed jar file in the Java
    plugin then I do not need to have a verisign or thawte
    certificate (however to allow my certificate to be
    accepted I do have to import it into the cacerts file
    on the client machine). True/false?true
    3. Following on from question 2, if I want to be able
    to run an applet on a client machine, without messing
    around with ANY files on those machines, I need a
    verisign or thawte certificate. True/false?true
    4. (And finally) Apart from a security exception
    saying that I need to add one of the lines like those
    of question 1, is there any way I can get other debug
    information as to why the signed jar file is not being
    recognised as signed?No. This could be a problem of importing your certifcate into the wrong place.
    The information on the following link is a little bit dated but it helped me to successfully install a testcertificate and sign an applet with it.
    http://www.suitable.com/Doc_CodeSigning.shtml

  • Quick Question **PLEASE HELP** .jar file?

    Hey everyone, im pretty new to the java scene but I have a really quick question that hopefully someone can help me with.
    I'm really interested in making a .jar file out of my code. And basically I just want to make one. but i understand there are certain things like main class's, etc. that need to be made in order to make a .jar file.
    So basically Say I opened up a new project in blueJ. I made 1 new class called "main." Inside of it I had nothing for conductors and no variables declaired untill the bottom part where i write my code.
    say i write...
    System.out.println("hello");
    and that is it.
    What steps from there do i do to make a jar file and have it be able to be executed and SEE the "hello" printed somewhere NOT in blueJ??
    (I understand there is something about a "static" method? Im not really sure but if somoene could enlighten me on how to make a .jar file that would be great.)
    Thanks a lot everyone!
    Tom

    I don't know anything about BlueJ, but this section of Sun's tutorial explains how to
    write a program that outputs a single line of text to the console:
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html
    Deploying an application as an executable .jar file is covered here:
    http://java.sun.com/docs/books/tutorial/deployment/jar/index.html
    The first two sections - "Using JAR Files: The Basics" and "Working with Manifest
    Files: The Basics" - contain the information you need to understand this process.

  • A few questions about executable Jar files

    Hi,
    I have to make an a tutorial system and was going to make it using applets embedded in webpages. This approach causes certain limitations so decided to make it using JPanels that open up as windows on the users computer.
    I intend on compressing all the files (java, images, sound etc) within a Jar file and would like a few questions answering.
    1. How would I make an executable Jar file that when clicked on will load the program on the users computer. Is there some software to do it for me or do I have to do it from the command prompt?
    2. Is using a Jar file the best approach or is there a better way to get my java program to run on other peoples pc's
    3. If I create an executable Jar file on windows xp, will it run on a Linux machine?
    Cheers

    1. How would I make an executable Jar file that when clicked on will load the program on the users computer. Is there some software to do it for me or do I have to do it from the command prompt?The SDK contains all the tools you need. Use the jar command. To make your jar executable, include a manifest file that references your main class.
    2. Is using a Jar file the best approach or is there a better way to get my java program to run on other peoples pc'sA jar will work just fine.
    3. If I create an executable Jar file on windows xp, will it run on a Linux machine?Yes.

  • Please help me 2 find a Document for this jar file com.sap.workflow_api

    HI,
    I want to create a task in UWL using web dynpro application. For this I need to import the specified com.sap.workflow_api.jar jar file.
    This jar file is in our WEB AS Server
    path=
    server\c\usr\sap\W01\JC00\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\WEB-INF\portal\portalapps\com.sap.workflow.apps\lib
    I have browsed all over for a good document , i got just one link :
    http://help.sap.com/saphelp_nw70/helpdata/EN/46/94b9b2b321581ce10000000a1553f7/frameset.htm
    Could you help me out with a better document for This task and  I want the complete document for this particular jar file com.sap.workflow_api.jar.
    It wolud be very helpful if I could get it at the earliest.
    Regards,
    Boopathi M

    HI Ayyapparaj,
    I have converted my project to javadoc,but i don't get any document for specific class. only I got what ever method is avilable in our controller that corssponding method come over in the java doc.
    How can i get the document for specified IWorkflow interface ? this com.sap.workflow_api jar file has IWorkflow interface. I need to know how to use this IWorkflow interface.
    How to use javadoc tool ?
    Regards,
    Boopathi M

  • To create a desktop shortcut icon for the application for a jar file

    Hi
    I have created a jar file for my application. when i double click this jar file, the application opens.
    What i want is--
    Instead of user clicking on the jar file, my application also has to create a desktop shortcut icon.
    If the user clicks on the icon which is on the desktop the application should open.
    Please suggest me.
    Thanks in advance.

    >
    Please suggest me.>Launch the application using java webstart. A webstart launch offers things like a splash screen, automatic updates, and desktop integration in the form of desktop shortcuts and program menu items. If the launch file specifies icons, they are used for the shortcuts, otherwise a generic icon is used.
    For a comparison between a sandboxed webstart launch and a plain app., try the [Text Width Checker|http://pscode.org/twc/].
    While the TWC can run OK within the security sandbox, many applications need to be digitally signed and request extended permissions, to do what they need to do.
    STBC is an all-permissions webstart launch.
    Edit 1:
    And for one that definitely suggests desktop shortcuts (I usually avoid them, in favor of a menu item only), try the sandboxed [demo of the PrintService|http://pscode.org/jws/api.html#prs], which prompts the user to choose.
    Edited by: AndrewThompson64 on Sep 2, 2008 10:49 PM

  • How to include images/icons for a jar file

    Hi,
    I need to create a jar file which will contain my application. My source code (.java) files are in "app" folder. I compiled that using javac -d . *.java and one package("appl") was created. I have all icons and images related to my application are in the folder named "icons" in the directory where source files are located i.e; app folder - "app/icons". I am accessing the images in the icons directory as "icons/book.gif".
    I created a jar file from source file directory with the option
    jar cvf app.jar app
    and i added this jar file to my classpath also.
    I have created a batch file to execute this application and set that batch file to "path" environment variable.
    It is running from any directory but no icons are appearing in that application if i try to run the application out side the "app" folder.
    Can any body give suggessions to solve this problem?

    Thanks for the added info, now let's get started.
    To use files in jars, you need to refer to them via a URL, so you'll need to modify your code a little bit first.
    URL imgURL = ClassLoader.getSystemResource("icons/BOOK.gif");
    setIconImage(Toolkit.getDefaultToolkit().getImage(imgURL));Next, you'll need a manifest. Using any text editor such as notepad, create a file called manifest.txt and put two lines in it. The first line will specify the class (w/o .class on the end) that contains your public static void main method, the second line is just an empty line (just press return).
    Main-Class: main
    (a blank line)
    Save this file with your class files (e.g. in Exam folder).
    Next build your jar. We want the jar to contain the package folder and your icon folder as well. So use this:
    jar cmf Exam/manifest.txt myJar.jar Exam/*.class icons
    And you should now have an executable jar. You can run it from dos with:
    java -jar myJar.jar
    or you can double-click it from windows.
    -Ron

  • Need inputs for creating Jar file

    Hi All,
      I am doing the scenario as file to mail. so here i am using java mappings for sending the file in mail attachment.
    as i can see in my system there are already one imported archive exists with name called "java_mappings".
    in that i can find 10 to 12 mapings which are used for different interface.
    i have tried to export the imported archive to my local system and created the project with same in NWDS.
    but here i can not find jar file.
    can anyone suggest how can i get jar file for already exist the imported archive.
    second option is if i want to create new mappings then how can i get the Jar file.
    thanks,
    Bhaskar

    Hi Bhaskar,
    Jar file is an archive which consists of all class files needed by Java mapping. If you have a folder named Java_mapping and you guess that it is being used in different interfaces, then it should have the class files in it... may be the source code is missing...
    I will suggest you to export it into your local machine and extract using winzip.. then you might see some file with .class extesnion. Try a tool like frontendplus which will make java code from java class file to get there code..
    Now if you are trying to make one for your requirement i would suggest to read the stefan grube blog..
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3414700%29ID1981012450DB01072979760660502867End?blog=/pub/wlg/4774
    Also note that the java mapping is just a jar file which has:
    1. the com.sap.xpi.ib.mapping.lib.jar (PI7.1) or aii_map_api.jar (PI7.0 or XI3.0) file
    2. You java code class file.
    Regards
    Suraj

  • Need help with classpath configuration for external jar files

    We have coded our own JAAS login module, and it uses classes located in jar files, and these jar files were not created using SAP dev studio, e.g. they were provided by a third party vendor as a set of tools.
    So, how do we deploy these jar files so that our SAP JAAS login module can find them ? We found we can run consoleconfig.sh to change the classpath which SAP J2EE engine uses, but we wondered if there was a better way to do this. Of course, if the jar files were created by us, we can include them in the dev studio project and they would be deployed using SDM, and this would not require any changes to classpath using consoleconfig.sh
    Thankyou in advance for your help.

    I noticed nobody has sent any feedback on this yet, so I wondered if I have posted to the wrong forum ? Any thoughts on this ?
    Thanks,
    Tim

  • Search for unused jar files

    Hi,
    We have a large project for which the set of dependent jars has grown large over the years. There is some suspicion now that we may be including jar files on the classpath that are no longer required.
    Does anyone know of a tool that can search a code base for usage of a particular jar? Obviously, it's a difficult task as there are a number of ways that classes may be imported/accessed (and reflection makes it impossible). It would be good if we could get some idea though of the jars that might be unused.
    This seems like a common task, has anyone seen (or developed) such a utility?
    Cheers,
    Joe.

    This really isn't an option. We're talking about an application with 1000s of classes.
    This also requires a LOT of manual intervention. Firstly to remove the statements (although this could obviously be automated), secondly to pick through the errors, add jars back etc to eventually compile a list of dependencies.

  • Lazy downloading broken for updated jar-files?

    Hello,
    Using webstart-6.0 + jar-index + download="lazy" works great - jar files are downloaded on demand when they are really needed.
    However when updating all jar-files, the files that have been downloaded lazily and cached before are downloaded again before the application can be launched, not only on demand.
    Is this the intended behaviour, and is there any way to let webstart lazily download updates, just when the jar-files are needed?
    Thank you in advance, lg Clemens

    Libraries loaded from the j2ee/home/lib directory are opened and loaded at the J2EE container level. So they are accessed from the very start of the server, to the point where it is stopped.
    Therefore if you modify a class library which has already been loaded, you may run into file locking related issues (which will be OS dependent, Windows for example probably won't even let you overwrite the file) so that is what you are likely to be seeing.
    JAR files loaded at the J2EE container level aren't really suitable for dynamic updating -- the classes can be referenced in a multitude of other classloaders.
    As you have seen, replacing a J2EE container level class file, then a restart will be required along the lines of what you have written.
    Stop mid-tier, move new file in and restart?? cheers
    -steve-

  • Launch Configuration for Eclipse JAR file

    Hi all, I am very new to Eclipse and pretty new to Java but I am just trying to create a simple JAR file that runs a system executable such as calc. Very easy :)
    I haven't had any issue running the code as an applet inside eclipse but when trying to create a runnable JAR, it doesn't give me any launch configurations to choose from. This doesn't make sense as I have launch configurations set up for it (under run.. run configurations I have two set up as Java Applets).
    import java.io.*;
    import java.applet.*;
    public class test2 extends Applet {
         public void init(){
              try {
                   Runtime.getRuntime().exec("calc");
              catch (IOException e) {}
    };Anyone have any ideas? If you need more info just let me know.
    Thanks
    -J
    Edited by: jaym3 on Nov 13, 2008 10:39 AM

    EJP wrote:
    Actually the default changed from "true" to "false" in Tomcat 7, but if it is set to "false" in Tomcat 6 it needs to be changed.Hm that I didn't spot. Thanks, I'll keep that in mind. Now I wonder what other settings just happened to have had their defaults changed... On some rainy afternoon I'll go figure that out.

Maybe you are looking for

  • Weird Pismo antics...

    OK...here goes...got a Pismo which has been behaving badly for a couple months...nothing earth-shattering...but causing enough annoyance for me to consider retirement (something I REALLY don't want to do...since it's my primary traveling machine)...

  • Long delay starting up in Leopard

    I have been finding that my Mac Mini is taking an inordinately long time to start up in Leopard 10.5.5. I have long delays in both the gray screen with the rotating gear, and also in the "blue screen" that appears afterwards. I have tried starting up

  • Revel sign in problem

    My Adobe ID and password work for Photoshop.com. But Revel keeps giving me an "unexpected error" message and rejects me. What can I do?

  • How Many Computers can I sync with?

    How many computers am I able to sync with?

  • I can not activate my IPAD mini

    I have tried to activate my ipad but get a message server cannot be reached any suggestions