How to make standalone program in java?

I have try use jar and it work. but how to access a folder that in the jar file?
example:
------files---------------------------------------------------------------
pic ( folder that storage images)
mainClass.txt (set where is the "main" class)
myclass.class
main.class
and i run in command line:
jar cmf mainClass.txt run.jar *.*
after that its created run.jar that store all files that i want
In main.class i get a images from a pic folder.
So how i get images from a pic folder after i make a standalone jar file ( get a path of image (up one folder of my main.class folder) in jar file where my main.clss is in the jar file too ) ?
thx..

Actually i access my image from other class, class that not contain main class, let call myclass, myclass isn't contain main class
i hava set path
"ImageIcon icon" in the myclass.class
ImageIcon icon = new ImageIcon(myclass.class.getClassLoader().getResource(path));its error:
"Could not find the main class. Program will exit"
i try:
ImageIcon icon = new ImageIcon(main.class.getClassLoader().getResource(path));but the same error too..
Edited by: sayunara on Apr 18, 2008 2:05 AM

Similar Messages

  • How does a standalone program running in JDeveloper connects to Oracle

    Hi,
    Can anybody please answer me how does a standalone program running in JDeveloper10G is getting connected to Oracle ? Normally it should go and check the host address and DB service name in TNSNames.ora file and go ahead. With JDeveloper10 ever after changing the TNSNames.ora file name to some other name the program running in Jdeveloper is getting connected to database. Seems weird ? I was actually doing some testing with that. Anybody please tell me how does JDeveloper handles such situations...
    Regards
    CTR
    Edited by: user8325217 on Oct 9, 2008 2:54 PM

    Yes, it depends on the type of JDBC driver you are using. Oracle has two JDBC drivers for Java clients. The oci driver requires an installation of Oracle Client on each machine running the Java app, and has the potential to use the tnsnames.ora entries. The thin driver is pure Java, does not require Oracle Client, and therefore is not aware of tnsnames.ora files.
    You want to look in your code for the part that's establishing a connection to the db, and look at the URL, which will tell you the type of driver being used, for example "jdbc:oracle:thin" or "jdbc:oracle:ociX".
    You might want to check out the following FAQ on JDBC:
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm
    Brian
    Product Manager, JDeveloper

  • How to make "Levels" in simple java game

    I just wanted to know if anybody knew how to make "Levels" in a java game. In my case, it is to change two polygons that are used in the background. I think you have to use an array of some kind, but i dont really know.
    Here is my source, the polygons are by the massive ///////// areas.
    I cut out the majority of the program, because it was too long.
    public class collision extends Applet implements MouseListener,MouseMotionListener
        private  Image rickImage,mazeImage;
       Image Buffer;
       Graphics gBuffer;
       int x, y;
       int[] LeftWallX = {0,204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,0};
       int[] LeftWallY = {500,499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1};
       //int[] PlayAreaX = {204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
      // int[] PlayAreaY = {499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       int[] RightWallX = {500,500,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
       int[] RightWallY = {500,0,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       boolean mouseInside, collide;
       boolean rolled = false;
       boolean msg = true;
       int sX=204,sY=490,sW=12,sH=9;
       //Declare the rectangles
       Rectangle  movingRect,finshBloc,startBloc,oopsBloc;
       //Declare the polygons
       Polygon leftWall,playerArea,rightWall;
            ///Initiate
            public void init()
                 rickImage = getImage(getDocumentBase(), "rick.jpg");
                 mazeImage = getImage(getDocumentBase(), "maze1.jpg");
                 collide=false;
                 Buffer=createImage(getSize().width,getSize().height);
                 gBuffer=Buffer.getGraphics();
                 rightWall=new Polygon(RightWallX,RightWallY,18);
                 playerArea= new Polygon(PlayAreaX,PlayAreaY,31);
                 leftWall= new Polygon(LeftWallX,LeftWallY,17);
            public void paint(Graphics g)
                 drawStuff();
                 g.drawImage (Buffer,0,0, this);
    */

    I'm not exactly sure in your case what you are trying to accomplish. If all you want to do is make new polygons for your levels then you will simply need a Vector of type level (or polygon). Store multiple levels/polygons in that vector. This can be done many ways, probably the most efficient way would be to create a class Level of sorts and create each level object from there. This way you have all your levels stored into that vector.
    I have made programs where the levels/mazes are randomly generated based on certain parameters (this way you would not need to define any specific level). This can be done inside the Level class and added to the vector so that when a level is randomly generated there are literally infinite possibilities. I would suggest posting all your code or at least a breakdown UML diagram of what is going on in your entire program.

  • Is it possible to create java standalone programs with java ME 8

    Hi,
    Comparing java ME to java SE, I have the impression that midlets are similar to applets.
    When working with java SE, I usually make standalone programs.
    Now, I wonder if it is also possible to create also standalone programs for java ME, if the classes are only  using java ME API's.
    I already noticed that netbeans does not allow to build a project that does not contain a midlet, but maybe, it is possible to create a jar file
    using the javac and jar commands. Or is there a specific reason why netbeans does not allow to build a project without midlets?
    The reason for asking is, that I often make small tools in java that ae then called from a linux script. I imagine that this might be useful on the raspberry pi as well.
    Thanks in advance
    Jef

    Hi Jef -
    Comparing java ME to java SE, I have the impression that midlets are similar to applets.
    Sort of - similar life cycle methods - so conceptually, yes.
    Now, I wonder if it is also possible to create also standalone programs for java ME, if the classes are only  using java ME API's.
    In a way, yes. If you build an project, you will notice a JAD file and JAR file in the dist directory of the project.  JAD is the descriptor for a MIDlet - in mobile devices, the JAD
    file is loaded first to determine if the MIDlet has enough privileges to load and run, before the corresponding JAR file is downloaded.
    However, the JAD file can also be included in the Manifest of the JAR and the JAR copied to the embedded device manually and run there.
    I already noticed that netbeans does not allow to build a project that does not contain a midlet, but maybe, it is possible to create a jar file
    using the javac and jar commands. Or is there a specific reason why netbeans does not allow to build a project without midlets?
    You can build JAR files and include them into Java ME Embedded projects, but just like Applets, to use the Application Management System (AMS) on the Raspberry Pi, you must have a MIDlet to run.
    Perhaps you mean that you would like to launch the AMS and load a MIDlet from the command line on the Pi?
    If so, take a look at this section of the Getting Started Guide for the Raspberry Pi.
    Tom

  • How to make destop application using java

    how to make destop application using java
    i mean to say when we double click on the exe file the program should lounch the application
    for windows

    when i double click ii got the msg
    Failed to lad main class manifest attribute from
    x/x/xyz.jar
    what exatly it meansIt means that your Manifest.MF for the JAR file should contain an attribute called Main-Class pointing to a class containing the main() method.
    Something like this should be present in META-INF/Manifest.MF :
    Main-Class: MyApplicationMain

  • How to make my program forcefully errror

    hi 2 all
    how to make my program forcefully error out even i have to get data
    regards
    siva

    Hi Mate,
    Just remove the quries which you execute
    Thanks
    Kash
    www.mkashu.blogspot.com

  • How to make labview program to get average value of 200 reading from multimeter (by using loop)

    Hello
    How to make labview program to get average value of 200 reading from multimeter (I using using loop) to read voltage from mulmeter  but I like to get average value of all of 200 reding how can I do that?
    Thanks
    Wee
    Solved!
    Go to Solution.

    Another idea with less programming - take advantage of the "free" array that comes with a Chart - i.e. the  History Data.
    1) Wire your DMM data to a Chart. (You can set the chart to invisible if you don't plan on using it in the GUI).
    2) Set the Chart History Length to 200 (right click on the chart, click on Chart History Length...)
    3) On the block diagram, use the History Data Property Node, wire it to Mean.vi, and you're done.
    Easiest running average ever.
    Message Edited by Broken Arrow on 04-07-2010 11:36 AM
    Richard
    Attachments:
    EasyAvg.jpg ‏8 KB

  • How to run native program with Java program?

    Hello
    I've got following problem. I'd like to write file browser which would work for Linux and
    Windows. Most of this program would be independent of the system but running programs not. How to run Linux program from Java program (or applet) and how to do it in Windows?.
    Cheers

    Try this:
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("ls -l");
    InputStream stream = proc.getInputStream();
    InputStreamReader isr = new InputStreamReader(stream);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null) .....
    "if the program you launch produces output or expects input, ensure that you process the input and output streams" (http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html)

  • How to make a program for backgroung processing used servlet

    how to make a program for backgroung processing used servlet

    well i need the coding part written in servlet ,in which servlet is always ready for accepting a client request.

  • How to make plsql parser around java method

    can someone tell me how can i move Jdeveloper java method into oracle DB (how to make plsql parser around java method). Is this possible becouse in google i can not find any good example how to make this.

    Hi,
    I think you are talking about Java Stored Procedure (?)
    Look here, http://download.oracle.com/docs/cd/E11882_01/java.112/e10588/toc.htm
    Regards
    Peter

  • Help on how to make a program on Calendar of the year

    I'm new to java programming.
    Our teacher assigned me to make a program for a calendar of the year.
    I'm confused on what to do. Could you give me some tips on how to
    make a successful calendar of the year program?
    What shall I study first to create an output like this....?
    The program should run like this!!!!
    Enter the year from 1990 to year 2050.
    Enter the month of the year entered.
    Then displays the calendar.
    Ex.
    SEPTEMBER 2002
    Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5 6 7
    8 9 10 11 12 13 14
    15 16 17 18 19 20 21
    22 23 24 25 26 27 28
    29 30
    Hoping that you would reply.
    Thank you very much!!!

    Don't want to do your homework. You should think about how you might do it yourself first.
    However, the class java.util.Calendar will be useful to you. Read up on that in the API docs.

  • How to make my program case - in sensitive?

    Hi,
    Iam writing a SELECT query in report for retrieving the address number by giving address details like street, city and post code.But my program is case sensitive such that if the user inputs either in Upper Case or Lower Case, it will not work.
    For eg: suppose the city is Cape Town. If the user inputs like CAPE TOWN or cape town ( via Selection Screen ), then it won't work.
    How can i  make my program case- in sensitive?? please suggest..

    This is possible. I have done something similar to it in my search programs.
    For this we need to make a subroutine. In this subroutine we first need to convert the case into upper case using
    TRANSLATE string TO UPPER CASE.
    then prefix and postfix this string with &,
    _and if this does not work then we have to break the srting entered by the user on basis of spaces and prefix and postfix it with &. _
    Now pass this string to the query and it will definitely get the result.

  • How to execute external program in java?

    My question is how to execute an external program in java.
    I need to call a unix command in java.
    Thanks.

    it depends on what you are trying to do. Following are the two methods
    1. Runtime.exec() : this method allows you just to call an external program as a seperate process
    2. JNI (Native Interface) :- As of right now only C and C++ are supported by this method. This method allows you to directly call the C/C++ methods from JAVA

  • How to make a program run in background?

    Is there any ways to make an invisible program with java? a program that is running in background but the user cannot see it and it's not in the Start bar and the user cannot close it.

    There are also 3rd party software that lets you install a java program as a service in winnt/2k/xp so that you can start/stop it from the service manager, doesnt even matter if the java program is gui based or not, as there are options (in win2k at least) in the service manager that allows the program to interact (think show gui) or not...one software called JNT comes to mind..
    Anyway, if you're using win98/me equivalent, then just use javaw.exe like suggested by previous posters.

  • How to make my program faster?

    I have a program which produces two elements array. In normally the program ends in microseconds, however when I organize my program to send the array as a data to DAQ.mx write and the array will be the voltage output from my NI USB-6012 DAQ, my program ens in 40 seconds. How can I make my program faster? Is there any solution?
    I have attached the normal program and with DAQ.vis.
    Attachments:
    step step 1.vi ‏15 KB
    step step 2.vi ‏34 KB

    Program 1 runs 5 times and program 2 runs 41 times per loop. the total number of inner iterations is 25 vs. 1681 for a 67x difference.
    Program 1 and program 2 have no timing information, thus spin at a undefined rate.
    Program 2 does single point hardware IO and also has no timing information. The speed will depend on the hardware.
    Running at a hardware dependent rate is not a good idea in general, because the speed will vary with every change in hardware and is not deterministic. You don't even know what occurs first at each iteration: the input or the output.
    If speed is important, what you should do is use an improved variation (Yes, use FOR loops and ramps!) of program 1 to generate the final data array, then do a single "Nchan,Nsamp" IO, running input and output synchronized hardware timed off the same clock. This way you can select any acquisition speed up the the maximum supported by your DAQ hardware. It will be fast and at an exactly defined rate as it should be!
    Try it!
    I am not familiar with your hardware: USB-6012. can you give a link to the product page?
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • QuickTime 7.1.6 Gamma/Color Shift Is Demonstrable

    You can easily see the undesirable behavior of gamma/color shifting when playing H.264 codec movies in Apple's QuickTime Player. Download any Apple HD (1920x?) QuickTime Trailer. Open and switch view to Double Size. The movie will immediately become

  • [Qosmio X300] How to get MaxxAudio tab in realtek hd audio manager again?

    First, sorry for my bad english, but I need your help =) After I updated my audio driver (realtek hd audio) the MaxxAudio tab in the realtek window was lost... To fix it, I have tried to "downdate" my driver, but I always can't see MaxxAudio. I have

  • Inserting HTML in JEditorPane

    Extremely frustrating trying to work with the HTML editing model (JEditorPane - content type text/html). I am using 1.4.2_06. Tying some basic actions to buttons or keystrokes is no problem (eg bold, italic etc.) but the most NB things like being abl

  • My photo albums used to be sorted by name now they are sorted by date (ipod touch ) any ideas?

    my photo albums on my ipod touch were sorted by name now they are sorted by date taken .I didn't change any settings on my computer any ideas?

  • SSI with Servlet... tag question

    I've been trying to get the <SERVLET NAME=... tag working with WL5.1. After           finding that the wall is indeed harder than my head after beating on it for           a while, I need to cry for help. Can anyone spot what step I've missed? I