Java file windows share

Class Data Sharing

Overview

Class data sharing (CDS) helps reduce the startup time for Java programming language applications, in particular smaller applications, as well as reduce footprint. When the JRE is installed using the installer, the installer loads a set of classes from the system jar file into a private internal representation, and dumps that representation to a file, called a «shared archive». If the JRE installer is not being used, this can be done manually, as explained below. During subsequent JVM invocations, the shared archive is memory-mapped in, saving the cost of loading those classes and allowing much of the JVM’s metadata for these classes to be shared among multiple JVM processes.

Class data sharing is supported only with the Java HotSpot Client VM, and only with the serial garbage collector.

The primary motivation for including CDS in Java SE is the decrease in startup time it provides. CDS produces better results for smaller applications because it eliminates a fixed cost: that of loading certain core classes. The smaller the application relative to the number of core classes it uses, the larger the saved fraction of startup time.

The footprint cost of new JVM instances has been reduced in two ways. First, a portion of the shared archive, currently between five and six megabytes, is mapped read-only and therefore shared among multiple JVM processes. Previously this data was replicated in each JVM instance. Second, since the shared archive contains class data in the form in which the Java Hotspot VM uses it, the memory which would otherwise be required to access the original class information in rt.jar is not needed. These savings allow more applications to be run concurrently on the same machine. On Microsoft Windows, the footprint of a process, as measured by various tools, may appear to increase, because a larger number of pages are being mapped in to the process’ address space. This is offset by the reduction in the amount of memory (inside Microsoft Windows) which is needed to hold portions on rt.jar . Reducing footprint remains a high priority.

Regenerating the Shared Archive

Under some circumstances the system administrator may need to manually regenerate the shared archive. This is typically only necessary on Solaris if the Java SE packages were installed over the network to a machine of a different architecture than that performing the installation. Regardless, these regeneration instructions apply to all supported platforms.

The shared archive file is colocated with the shared library for the JVM. On Solaris, Linux, or Mac OS X platforms, it is stored in jre/lib/[arch]/client/classes.jsa and on Microsoft Windows platforms in jre/bin/[client or server]/classes.jsa . If this file exists, it must be manually removed before regeneration.

To regenerate the archive, log in as the administrator; in networked situations, log on to a machine of the same architecture as the Java SE installation and ensure that you have permission to write to the installation directory. Then execute the command

java -Xshare:dump Diagnostic information will be printed as the archive is generated.

Manually Controlling Class Data Sharing

The class data sharing feature is automatically enabled when conditions allow it to be used. The following command line options are present primarily for diagnostic and debugging purposes and may change or be removed in future releases.

Читайте также:  Qualcomm atheros ethernet controller windows 10

-Xshare:off Disable class data sharing. -Xshare:on Require class data sharing to be enabled. If it could not be enabled for various reasons, print an error message and exit. -Xshare:auto The default; enable class data sharing whenever possible.

Open a file from network share

  • There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

  • fred rosenberger wrote: What have you tried? What did it do (or not do)? If you really want help, you need to TellTheDetails.

  • fred rosenberger wrote: What have you tried? What did it do (or not do)? If you really want help, you need to TellTheDetails.

    I have tried what I found when I googled which were examples using Desktop.

    This would work if the file is on my local machine, but does not work with a network path.

  • fred rosenberger wrote: What have you tried? What did it do (or not do)? If you really want help, you need to TellTheDetails.

    The code I posted above, opened a file on my local machine, but would fail anytime I tried to open a file on a network path.

  • Richard Marx wrote: Let me also add that my network path will have spaces in the network path. So that may throw a wrench in the way that the file will be opened.

    I have also tried to run

    The output displays the proper path & filename.
    But when it try’s to open I get this error:
    Caught IOException: Failed to open file: \\\\ServerName\\Folder1\\Folder2\\Folder 3\\ReportsAlpha.xls
    Error Message: The system can not find the file specified.

    The file exists. If I go to start and run and I copy paste the location from my new file dialog there, it will actually open the workbook.
    So either my code is way wrong, or I am attempting to open a file on the network incorrectly.

  • Caught IOException: Failed to open file: \\\\ServerName\\Folder1\\Folder2\\Folder 3\\ReportsAlpha.xls

    Because \ is the escape character within the string literals, so

    should show up as
    \\ServerName\Folder1\Folder2\Folder 3\ReportsAlpha.xls

    which appears to be your intention.

    Or maybe you do not copy-and-paste (which you should) the error but reinterpet/rephrase it (which you should not).

  • Ivan Jozsef Balazs wrote: This is very suspicious:

    Caught IOException: Failed to open file: \\\\ServerName\\Folder1\\Folder2\\Folder 3\\ReportsAlpha.xls

    Because \ is the escape character within the string literals, so

    should show up as
    \\ServerName\Folder1\Folder2\Folder 3\ReportsAlpha.xls

    which appears to be your intention.

    Or maybe you do not copy-and-paste (which you should) the error but reinterpet/rephrase it (which you should not).

    I did hand-type it, let me copy/paste the error this go round:
    Caught IOException: Failed to open file:////ServerName/Folder1/Folder2/Folder%203/ReportsAlpha.xls
    Error Message: The system could not find the file specified.

  • Richard Marx wrote: I did hand-type it, let me copy/paste the error this go round:
    Caught IOException: Failed to open file:////ServerName/Folder1/Folder2/Folder%203/ReportsAlpha.xls
    Error Message: The system could not find the file specified.

    Looks to me like you’ve doubled up forwards slashes in your String when you don’t need to. Only back-slashes need to be duplicated; and you don’t need to use those for path names in Java; it’s exclusively a Wndows thing.

    «Leadership is nature’s way of removing morons from the productive flow» — Dogbert
    Articles by Winston can be found here

  • Richard Marx wrote: I did hand-type it, let me copy/paste the error this go round:
    Caught IOException: Failed to open file:////ServerName/Folder1/Folder2/Folder%203/ReportsAlpha.xls
    Error Message: The system could not find the file specified.

    Looks to me like you’ve doubled up forwards slashes in your String when you don’t need to. Only back-slashes need to be duplicated; and you don’t need to use those for path names in Java; it’s exclusively a Wndows thing.

    Читайте также:  Fortinet vpn client windows

    So everywhere in the string would just need to be single slashes? — If that is the case it won’t even compile anymore.
    If I reduce the 4 slashes to 2 at the beginning of my string so it reads: //ServerName/Folder1/Folder2/Folder%203/ReportsAlpha.xls I then get an error of:
    Exception in thread «AWT-EventQueue-0» java.lang.IllegalArgumentException: The file: \ServerName\Folder1\Folder2\Folder%203\ReportsAlpha.xls does not exist.

  • Richard Marx wrote: So everywhere in the string would just need to be single slashes? — If that is the case it won’t even compile anymore.
    If I reduce the 4 slashes to 2 at the beginning of my string so it reads: //ServerName/Folder1/Folder2/Folder%203/ReportsAlpha.xls I then get an error of:
    Exception in thread «AWT-EventQueue-0» java.lang.IllegalArgumentException: The file: \ServerName\Folder1\Folder2\Folder%203\ReportsAlpha.xls does not exist.

    I think you need to show us your code; but the fact is that you shouldn’t use backslashes for path names in Java:
    1. It’s only Windows that specifies paths in that bizarre way.
    2. Backslashes in Java Strings are used for escaping, which is why you have to double them up, which makes things mighty confusing.
    3. There may be problems with the ‘%20’ notation (I’d have to check the docs again, because it’s been a while).

    But first: show us your code, because it’s difficult to know what’s wrong until you do.

    «Leadership is nature’s way of removing morons from the productive flow» — Dogbert
    Articles by Winston can be found here

  • Richard Marx wrote: So everywhere in the string would just need to be single slashes? — If that is the case it won’t even compile anymore.
    If I reduce the 4 slashes to 2 at the beginning of my string so it reads: //ServerName/Folder1/Folder2/Folder%203/ReportsAlpha.xls I then get an error of:
    Exception in thread «AWT-EventQueue-0» java.lang.IllegalArgumentException: The file: \ServerName\Folder1\Folder2\Folder%203\ReportsAlpha.xls does not exist.

    I think you need to show us your code; but the fact is that you shouldn’t use backslashes for path names in Java:
    1. It’s only Windows that specifies paths in that bizarre way.
    2. Backslashes in Java Strings are used for escaping, which is why you have to double them up, which makes things mighty confusing.
    3. There may be problems with the ‘%20’ notation (I’d have to check the docs again, because it’s been a while).

    But first: show us your code, because it’s difficult to know what’s wrong until you do.

  • Richard Marx wrote: Java is adding in the %20 in the space, I do not have that hardcoded, below is my code that I am running

    OK, now we can get somewhere; but I’m afraid nothing leaps out at me.

    First: I’d take out the Desktop stuff for the moment and just test it with a simple File. Does File.exists() return false?

    Second: Have you tried creating a URI instead (don’t forget to add «file:», and I’d suggest using forward slashes (undoubled)), and then testing whether you can connect to it with toURL.openConnection().connect()? That might help you to work out where your problem is occurring, and as soon as you get that working, you can then create a File using the URI.

    Читайте также:  Установить браузер google для windows 10

    My problem is that I (and possibly you) don’t know enough about Desktop or what it does with Files to speculate, so if you remove that layer and just test with basic classes, you may be able work out what the problem is more easily.

    Alternatively, someone cleverer than me may be able to tell you exactly what your problem is.

    «Leadership is nature’s way of removing morons from the productive flow» — Dogbert
    Articles by Winston can be found here

  • Richard Marx wrote: Java is adding in the %20 in the space, I do not have that hardcoded, below is my code that I am running

    OK, now we can get somewhere; but I’m afraid nothing leaps out at me.

    First: I’d take out the Desktop stuff for the moment and just test it with a simple File. Does File.exists() return false?

    Second: Have you tried creating a URI instead (don’t forget to add «file:», and I’d suggest using forward slashes (undoubled)), and then testing whether you can connect to it with toURL.openConnection().connect()? That might help you to work out where your problem is occurring, and as soon as you get that working, you can then create a File using the URI.

    My problem is that I (and possibly you) don’t know enough about Desktop or what it does with Files to speculate, so if you remove that layer and just test with basic classes, you may be able work out what the problem is more easily.

    Alternatively, someone cleverer than me may be able to tell you exactly what your problem is.

    Simply running this:

    Will return File exists.

    Now for your 2nd recommendation I have not tried using URI as I am beginning Java. I will google and see what results I can return from that and see if I can create a working example. Thank you for the help thus far.

  • Richard Marx wrote: Now for your 2nd recommendation I have not tried using URI as I am beginning Java. I will google and see what results I can return from that and see if I can create a working example. Thank you for the help thus far.

    No probs. My problem is that I simply haven’t done that stuff recently enough to help more — and I’m not in a position to set up a network share to try it out.

    However, it’s generally a good rule when dealing with problems like this to remove as much «middleware» stuff (like Desktop) from the equation as you can and test with basic components.

    BTW: If you go the URI/URL route, I’d also split up the process completely, viz something like:That way you’ll see exactly where the error is occurring if one does. If all of that works fine, then you can create a File, then a FileInputStream, and try and read from it; but do it all in separate statements, just as if you were showing the individual steps to a kid.

    And like I say, it’s very possible that someone will get off work, come here, and see immediately what your problem is. I have to use old-fashioned «try this» logic.

    «Leadership is nature’s way of removing morons from the productive flow» — Dogbert
    Articles by Winston can be found here

    Оцените статью