Breakpoint inside JAR

I am trying to set a breakpoint on a source file I have inside a JAR sitting in my project's WEB-INF/lib directory. Its corresponding compiled class is also in the same JAR. I set the breakpoint by opening up the jar within Jdev's archive viewer. From there, I opened the source file and set the breakpoint. When I debug, the breakpoint is never hit when I know it should be. I also have this JAR file listed in the sourcepath of the project settings. My class in the jar was compiled with the debug="on" attribute of the Ant compile task. I am using Jdev 9.0.4.0 (Build 1419). Is it possible to do what I am trying?

Standard java cannot use a jar that is within another jar. You could write your own classloader, or look at a product named "onejar".
Here is a tutorial that shows you how to package a NetBeans project so it can be executed outside of NB.
http://www.netbeans.org/kb/articles/javase-deploy.html

Similar Messages

  • How to edit a text file inside jar

    Hi all;
    I have a code that created text file and put this file to other jar archive.
    How can I edit this text file inside jar, add string to this file ?
    Thanks,

    Unpack the jar, edit the file, repack the jar.

  • Resources inside JAR - problem

    I have a strange problem with resources inside JARs.
    I can't load any resource form a JAR file (for example a .property file or .png icon).
    It's not a problem with my progams only. JDBC drivers doesn't work because they cannot find .properties files while they work well when, the driver JAR i uncompressed. It happens every time when some resouces are inside JAR library (classes are loade correctly). The same project runs well on my friend's computer while I've got an error on my computer.
    I tried it on WinXP and Win2003 Server - the same. My java version 1.5.0_06-b05 (but I had the same problem with older versions).
    I figured out that I can find a file inside a JAR, open a stream, load data and everything is OK but data is always 0bytes length. For example using:
    ImageIcon myImageIcon = new ImageIcon(getClass().getResource(pathandfilename));
    I get empty ImageIcons without any error.
    Can anyone help me. Maybe I should find something somwhere in java configuration.
    Message was edited by:
    peper

    But can anyone tell me why my servlet can not access the
    contents inside a jar file?? Any suggestions please?
    Thanks.Without seeing your code, it is likely that you are trying to use file names (like /some/path/yourFileName.ext), not resource names (loadable from the class loader) like /yourFileName.ext.
    Example:
    Instead of:
    FileInputStream stream = new FileInputStream("/some/path/yourFileName.ext");
    do this:
    InputStream stream = getClass().getResourceAsStream("/yourFileName.ext");
    There are other API's which take either a string file name or a URL. You want to go the URL way, where the URL is taken from the classpath as:
    URL url = getClass().getResource("/yourFileName.ext");

  • Classnotfoundexception eventhough the class is inside jar

    Hi guys,
    I encountered weird problem where sometimes it throws classnotfoundexception eventhough the class is inside jar. I terminate the program and start it again then it works fine. I compiled the jar using ant
         <target name="compile" depends="clean" description="">
               <echo message="using java version    : ${java.version}"/>
               <echo message="using ant.java.version: ${ant.java.version}" />          
                 <javac srcdir="${src.dir}"
                        destdir="${build.dir}"
                        debug="on"
                        source="1.5"
                              excludes="com/csg/cs/mud/junit/*"
                 />
                <jar destfile="${mmd.jar}"
                     basedir="${build.dir}"
                     excludes="org/css/cs/mmd/juni*,org/css/cs/mmd/utility/MDDClient.class"
                />          
         </target> it shows :
    *[echo] using java version : 1.5.0_04*
    *[echo] using ant.java.version: 1.5*
    and I deployed this jar to sun solaris (SunOS sg123-456 5.8 Generic_117350-44 sun4u sparc SUNW,Ultra-80) and sun solaris box is using jre1.5.0_06.
    Appreciate any advice please. thanks in advance!
    Cheers,
    Mark
    Edited by: kmthien on Aug 2, 2010 3:05 AM

    Is it public?
    Is it spelt correctly, and the same, in the jar file and the code?
    Is it in its correct package in the jar file?
    Why are you excluding a class from the jar file?

  • Finding total number of class files present inside jar

    Is there any way to find the total numbef of class files present inside jar?
    Any link will be helpful.

    http://java.sun.com/j2se/1.4.2/docs/api/java/util/jar/JarFile.html#entries()
    You'll have to search through it.

  • Acess DB inside jar

    Hai everyone,
    I developed a swing application which uses MS Access ,database.
    I packaged the application as a jar file. I also included the
    database inside the jar. But it is unable to connect to the
    database when the database is inside the jar. If database is ouside
    the jar, the application works fine. I used the following code for the database
    connectivity .
    Is it wrong to pack a database inside jar ?
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String dbPath = getClass().getResource("Test.mdb").getPath();
    dbPath = dbPath.substring(dbPath.indexOf("/")+1);
    String connectionString =
    "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + dbPath;
    System.out.println(dbPath);
    con = DriverManager.getConnection(connectionString);
    stmt = con.createStatement();

    Standard java cannot use a jar that is within another jar. You could write your own classloader, or look at a product named "onejar".
    Here is a tutorial that shows you how to package a NetBeans project so it can be executed outside of NB.
    http://www.netbeans.org/kb/articles/javase-deploy.html

  • File Not Found inside jar

    Hi All,
    Im using applet to access a wav file which is located in the jar file, 1st of all im compiling the applet class, making a jar file(which has the welcome.jar in it) and signing the jar file and then archiving the jar file in the HTML code. following is the code used in the java applet file.
                    URL pathShell = null;
         Object dummy = new Object(){
                                 public String toString() { return super.toString(); }
         ClassLoader cl = dummy.getClass().getClassLoader();
         pathShell  = cl.getResource("welcome.wav");
         String wavFile = pathShell.toString();
         System.out.println("path  --- "+pathShell);
         System.out.println("String -- "+wavFile);
         RandomAccessFile rcs = new RandomAccessFile(wavFile,"rw");Exception messages is as follows,
                   path  --- jar:http://localhost/slider.jar!/welcome.wav
                   String -- jar:http://localhost/slider.jar!/welcome.wav
                    java.io.FileNotFoundException: jar:http:\localhost\slider.jar!\welcome.wav (The filename, directory name, or volume label syntax is incorrect)
         at java.io.RandomAccessFile.open(Native Method)
         at java.io.RandomAccessFile.<init>(Unknown Source)
         at java.io.RandomAccessFile.<init>(Unknown Source)
         at AudioPlay.<init>(AudioPlay.java:40)
         at SliderDemo.startAudio(SliderDemo.java:231)
         at SliderDemo.access$000(SliderDemo.java:17)
         at SliderDemo$5.actionPerformed(SliderDemo.java:144)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

    b.m.kraju wrote:
    Hi All,
    Im using applet to access a wav file which is located in the jar file, 1st of all im compiling the applet class, making a jar file(which has the welcome.jar in it) and signing the jar file and then archiving the jar file in the HTML code. following is the code used in the java applet file.You can't open a resource inside a jar file as a RandomAccessFile or any other form of File.

  • How to Read all files inside resource Folder inside Jar?

    I have a Jar file,,,, The program reads for resource files in the resource folder inside the Jar. I want my program to read all files inside this folder without knowing the names or the number of files in the folder.
    I am using this to make an Applet easy to be updated with spicific files. I just want to add a file inside the resource folder and Jar the program and automatically the program reads what ever is in there!!
    I used the File class to get all file names inside the resource folder. it works fine before Jarring the program. After I jar I recieve a URI not Herarichy Exception!!
    File fold=new java.io.File(getClass().getResource(folder).toURI());
    String[] files=fold.list();
    I hope the question is clear!!

    How to get the directory and jar file that you class resides in:
    // returns path and jarfile (ex: /home/mydir/my.jar)
    public String getJarfileName()
            // Get the location of the jar file and the jar file name
            java.net.URL outputURL = YourClass.class.getProtectionDomain().getCodeSource().getLocation();
            String outputString = outputURL.toString();
            String[] parseString;
            int index1 = outputString.indexOf(":");
            int index2 = outputString.lastIndexOf(":");
            if (index1!=index2) // Windows/DOS uses C: naming convention
               parseString = outputString.split("file:/");
            else
               parseString = outputString.split("file:");
            String jarFilename = parseString[1];
           return jarFilename;
    }If your my.jar was in /home/mydir, it will store "/home/mydir/my.jar" in jarFilename.
    note: getLocation returns "file:/C:/home/mydir/my.jar" for Windows/DOS and "file:/home/mydir/my.jar" for windows, thus why I look for the first and last index of the colon so I can correctly split the string.
    If you want to grab a file in the jar file and get an InputStream, do the following:
    import java.io.*;
    import java.util.Enumeration;
    // jar stuff
    import java.util.jar.*;
    import java.util.zip.ZipEntry;
    public class Jaris
       private JarFile jf;
       public Jaris(String jarFilename) throws Exception
           try
                           jf = new JarFile(jarFilename);
           catch (Exception e)
                jf=null;
                throw(e);
       public InputStream getInputStream(String matchString) throws Exception
           ZipEntry ze=null;
           try
              Enumeration resources = jf.entries();
              while ( resources.hasMoreElements() )
                 JarEntry je = (JarEntry) resources.nextElement();
                 // find a file that matches this string from anywhere in my jar file
                 if ( je.getName().matches(".*\\"+matchString) )
                    String filename=je.getName();
                    ze=jf.getEntry(filename);
          catch (Exception e)
             throw(e);
          InputStream is = jf.getInputStream(ze);
          return is;
       // for testing the Jaris methods
       public static void main(String[] args)
          try
               String jarFilename=getJarfileName();
               Jaris jis = new Jaris(jarFilename); // this is the string we got from the other method listed above
               InputStream is=jis.getInputStream("myfile.txt"); // can be used for xml, xsl, etc
          catch (Exception e)
             // this is just a test, so we'll ignore the exception
    }Happy coding! :)
    Doc

  • Opening html files inside jar

    Hi,
    I'm making a program where i have a set of help files in the form of html and i would like to open them when the user clicks the "Help" button and I used this code at first
    try
         Desktop.getDesktop().browse(new URI("resources/html/help.html"));
    catch (Exception ex)
         JOptionPane.showMessageDialog(null, "Could not open help.html in default browser\n", "Error", JOptionPane.ERROR_MESSAGE);
    }However after I made the jar and tried to execute on another computer however, it wouldn't work and would display the error message. I was wondering if there was some way that I could open the help.html in their default browser, or maybe a frame if that works, from the jar and have my program still be platform independent?

    ok so i just realized that it doesn't make sense for a program outside the jar, like IE or Firefox, to be able to access and open a file inside of the jar. I am now looking for suggestions on how to work around this problem for my program to be able to have a simple help system located inside the jar that can be loaded during runtime.
    Thanks for your suggestions.

  • Validating xml-files inside jar-files  for JWS

    I want to use xml-files inside a jar-file and want to validate them with dtd-files,
    located in the same jar-file. This does work, but only as long as the dtd-file is
    in the same directory as the xml-file.
    For example, I have no problem, with a DOC Type-statement like
    <!DOCTYPE questestinterop SYSTEM "ims_qtiv1p1.dtd" >
    With this statement, however, one needs an approprate dtd in every directory containing an XML-file of that type.
    If however i want to gather the necessary dtd's in a directory one (or more) levels above with a DOCTYPE-statement of the form
    <!DOCTYPE questestinterop SYSTEM "../ims_qtiv1p1.dtd" >
    I get error messages of the form
    java.io.FileNotFoundException: JAR entry Mikro/Marshall/BookQuestions/../ims_qtiv1p1.dtd not found in C:\Dokumente und Einstellungen\wreiss\Anwendungsdaten\Sun\Java\Deployment\javaws\cache\http\Dwiwi.upb.de\P80\DM~vwl08\DMOViSS\DMoviss_current\RMMikro.jar
         at org.apache.crimson.parser.Parser2.fatal(Unknown Source)
         at org.apache.crimson.parser.Parser2.externalParameterEntity(Unknown Source)
         at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Unknown Source)
         at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
         at org.apache.crimson.parser.Parser2.parse(Unknown Source)
         at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
         at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(Unknown Source)
         at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
         at oviss.competenceCenter.XMLExpert.setElements(XMLExpert.java:245)
    though the dtd-file is in the parent-directory (inside the jar) and the unpacked xml-file can be successfully validated.
    Why does this happen. How can one use a single dtd for multiple xml-files (of the same type) in different directories?.
    Thanks
    Winfried Reiss

    In reply to myself, replacing the HTMLBrowser constructor with this;
    public HTMLBrowser()
                  URL url;
                  try
                       // Construct the URL
                       url= this.getClass().getResource('/'+dir+'/'+startPage);
                       setPage(url);
                  catch (Exception e)
                  System.out.println( "Problem setting help homepage");
                 setEditable(false);
                 addHyperlinkListener(new LinkListener(this));
            }made it work. This is because seemingly you need '/' at the start of the resouce's path and '/' as the separator, regardless of platform.
    I hope this helps someone else.
    John

  • Program does not break at breakpoint inside stored procedure

    I am using VS 2013 and SQL Server 2012 calling a stored procedure from a C# program. I have a breakpoint set inside the stored procedure, however execution does not stop on it. When my program is running, the breakpoint is hollow (not solid red) and the
    tool tip reads "the breakpoint will not currently be hit. No symbols have been loaded for this document".
    I built my app in debug mode and checked "SQL debugging" in the debug tab.
    Any idea as to what would cause my breakpoint to not work?
    Thanks!
    -A

    Hi achalk,
    When debugging SQL Server stored procedure in Visual Studio 2013, please make sure that Application Debugging is selected in "SQL Server Object Explorer", otherwise you will not be able to step into T-SQL.
    There are similar articles for your reference.
    Debug SQL Server 2012 Stored Procedure in Visual Studio 2013, Step by Step
    http://database.ca/blog.aspx?blogid=10
    How to debug SQL Server T-SQL in Visual Studio 2012
    http://stackoverflow.com/questions/12016417/how-to-debug-sql-server-t-sql-in-visual-studio-2012
    Thanks,
    Lydia Zhang
    If you have any feedback on our support, please click
    here.
    Lydia Zhang
    TechNet Community Support

  • Invisible class files inside jar archives

    Hi!
    After developing an application with J2SE 1.4.1_05, under Windows 98, using some packages archived in jar files, I cannot launch the application with the J2RE 1.4.2_02 or J2SE 1.4.2_02 (in the same Windows 98) because the class files in the jars are not 'visible', even if the CLASSPATH is set up correctly. The only classes that work right are the unpacked ones. But it still does work in Windows 2000.
    What might be wrong?

    Thank you for your answer, and excuse me if my question was kind of confusing.
    The issue here is that the files ARE in the jar files (without './' on the front), but in the environment (Windows 98 + J2RE 1.4.2_02) the application does not work, unless I unpack the jars and use the packages in the same manner I did during the development stage (for example, all classes of package 'myutils' in the folder 'myutils').
    The weird thing is that this DOES NOT happen in the environment (Windows 2000 + J2RE 1.4.2_02)!!! Just after installing the J2RE 1.4.2_02 under Win2K, the app does work OK! That is why it seems that ONLY in the first case (Windows 98 + J2RE 1.4.2_02) the class files inside the jars seem to be 'invisible' to the environment.
    As I have mentioned in my question, the app was developed in the environment (Windows 98 + J2RE 1.4.1_05), and it did still work with the jar files, so I wonder if there might be some compatibility between Windows 98 and the J2RE 1.4.2_02.
    Except my own jars, the same thing does happen with the jai_core.jar file coming with JAI 1.1.2. But this does not happen when it comes about rt.jar, in ..\jre\bin!!!
    All in all, the question still is: what might be wrong?

  • Accessing files inside JAR archives

    I have a jar file with structure as follows
    . root directory containing *.class files
    .\dll directory containing *.dll files
    .\images directory containing *.gif and *.jpg files
    Now, when i want to load the dll i use
    System.loadLibrary("dll/sendlib");or to load an image
    ImageIcon i = new ImageIcon("images/"+filename);This works perfectly when the program is not packed in a jar file. I have seen previously that you can use getResourceAsStream(), but in my case it won't work, since it's not class files i'm after. Anyone who have got this to work? Is there some special options in the manifest file that needs to be set, or is the directory structure inside the jar file not the same as outside? How shall i do to load my files?

    if u r using jar file u have to create url object.
    i.e
    URL url = MainclassName.this.getClass ().getResource("/images/"+fileName);
    ImageIcon i = new ImageIcon(url);
    it will work. MainclassName is the name of ur main class
    Paddy

  • Accessing files inside JAR

    Hello !
    I have a HTML file inside a JAR file. The HTML file uses images and stylesheet located in the same dir in the JAR.
    I need to access the HTML file so that I can open it in a JEditorPane for displaying as a normal HTML. I've been trying to access it with some examples i've gotten from the forum from previous posts, without any success. Could someone PLS post me some examples or point me to a webbie with some tutorial.
    I've already tried the following:
    editorPane = new JEditorPane(this.getClass().getResource("/file.html"));Oh, it is a stand-alone application, and all the files are in the same JAR. =)

    Try it this way:
    editorPane = new JEditorPane(ClassLoader.getSystemResource("file.html"));
    -Ron

  • Application starts IE and needs to access html inside Jar

    Hi everyone,
    I have a Swing application which i have deployed as an executable Jar file. One of the options i give the users within this application is the ability to view a html file in their default browser. However the html file is packaged within the jar and i cannot get Internet Explorer to target the html file when it exists inside the jar.
    I fire up IE using the following command :
    Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler <path to html file>" ).
    The above command works no problem if my html file exists on my hard drive so for example the following works no problem:
    Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler C:\test\help.html" )
    I have tried the following command by getting the URL for the html file using :
    URL theURL = myClass.class.getClassLoader().getSystemResource( "help.html" );
    I then get a path to the file:
    File aFile = new File( theURL.getFile() );
    String htmlFile = aFile.getAbsolutePath();
    and execute the command
    Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler" + " " + htmlFile )
    However this was not successfull either.Can anyone tell me how i might get internet explorer to display a html file which is packaged within a jar.
    Thanks :)

    An idea. Never tried anything like this myself, so don't know if it will work. Don't see why it shouldn't though.
    A jar file is just a file in the zip format so write some code that uses the tools in java.util.zip to unpack the jar (or just specific contents) to somewhere like /temp
    Then use the runtime exec to start the browser with the argument /temp/file.html
    Hope this helps.

Maybe you are looking for

  • How to get the month value in a date?

    I am retrieving a Date from the database using the getDate() method! However, I want the value of the month in this obtained result, which i want to compare with an integer! I dont see any other option but to use the deprecated getMonth() method on t

  • Period wise Quantity Distribution at Activity Level

    Dear All, As we know that period wise quantity distribution is possible but can it be editable & can we adjust the quantities manually?

  • Problem with my nokia 3110 classic

    Hi, in about a month before I tried to apply a theme and it displayed a message Unable to open theme. theme corrupted. What should I do? I'm afraid to do anything so that i don't make it worse. The only thing I tried is to upgrade my software, but it

  • Positive Value only Display or Edit Pattern

    Hello, could someone please explain how I can prevent a negative result in a calculation field? i.e., a result less than zero. In other words, how can I ensure that users only enter positive values in a numeric field, and that the subsequent simple "

  • My option-scissor function isn't working!

    When I use the command to slice the region at equal subdivions, it doesn't work Instead, it slices normally (one slice) even though the little plus sign by the scissor still shows. Any idea why this might be? I haven't updated anything except QT and