Limit to java?

Hi all,
I'm currently working on a project where I need to sort through (literally) hundreds of thousands of images. Basically, my program opens a folder, and loops through it - looking for the date modified of each image - takes the image out of the folder, and puts it in another folder according to its date modified. I'm just worried that since I am dealing with images on such a large scale - something might crash? I'm running it right now - and it seems to work - abeit very slowly. I'm planning to leave it overnight and see if it is finished sorting by then.
Is it possible to sort through the files in another way other than a loop?
Thanks!

nfw24 wrote:
I'm not quite sure what you mean by copying the images or moving them very fast?
I'm basically using the renameTo function from class File to move the images to their new directories.
He means are you copying them, or moving them. Copying takes a long time compared to moving, because you have to write the entire set of data to disk all over again. Moving only requires updating a couple attributes in the file system.
Based on your behavior I wouldn't be worrying about any "limits" in java since it sounds like you aren't even reading these images into memory. I think the only limit of any concern to you is disk space.
If you're not getting the performance you want you can post some code here, and also try profiling it yourself to see where your bottlenecks are. I've only used JProfiler, which I found remarkably satisfactory.
Edited by: nclow on Jun 19, 2008 7:14 PM

Similar Messages

  • What is virtual limit of Java?

    I hadn't actually tested the memory limitations of the jvm before and I was taking the word of others (and I didn't have access to Sun boxes always either.) So I decided to test the limits today.
    Windows:
    -NT
    -1.0 gig memory limit (512 physical, 512 virtual)
    -Jdk build 1.3.1-b24
    Using only option "-Xmx" and a 'hello world' program I run into a limit at 1649m, 1648m works and 1649m doesn't.
    Solaris:
    -2.7
    -750m total memory (512m physical)
    -Jdk build 1.3.1-b24
    I run into a limit at 3957m, 3956m works.
    When I exceed the limit I get this message when the jvm is started.
    "Could not reserve enough space for object heap"
    I would like to confirm those numbers with others and see if the numbers vary with different OSes and jvm versions.
    So if you have any useful information to contribute please do.

    vickyk said
    I would like to clarify the difference between the following :
    1)Heap Memmory
    2)Stack Memory
    3)Actual Ram
    i had read in some sources that heap and stack are
    a part of the ram.Well that isn't true. In all modern OSes (precluding real time) stack and heap are part of the process space which is all mapped into virtual memory. When actually running all virtual memory is loaded into physical memory (ram.) But in any substantial application the heap is one of the most likely things to be swapped to the hard drive.
    And it helps to be clear which heap and stack you are talking about. When you run a JVM there are TWO different types of stack/heap. One is for the process and is supplied by the operating system to the executable. The second kind is provided by the JVM and is used by the running byte codes. The two types are not the same.
    In Mastering Java it has been mentioned how the heap and
    stack work.The heap does
    contain the references of the object and the instances
    are stored in stack.Huh? Parameter references and local references are on the stack. Class references (static or not) are on the heap with the rest of the object data. An 'instance' should be deemed to be the real object and that will always be on the heap, it will never be on the stack.
    Once I set the initial heap more than the actual total ram doesnot the OS give
    the excess asked from the
    hard disk or from some other form.If it doesnot give then
    how for the process you can set heap size more than
    the actual ram available?No.
    When you specify the maximum that is how much it might ask for, not how much it gets on start up. If you specify the minimum then that is asked for on start up.
    The analysis done with setting the maximum heap size
    gave the following results:
    Case 2:
    java -Xmx1674m Ora is the maximum results
    Case1:
    Oops here I am getting amzing results????
    java -Xmx8m Ora works
    java -Xmx1468 Ora gives Error
    java -Xmx12468 Ora works fineIn the second case you exceeded the internal maximum for the JVM. It will not let you go over that limit.
    Is specifying these parameters keep the range of the
    memory give to the JVM(process)?What is the default
    value given to the maximum Java heap Size.See the java docs for your particular jvm. For Sun 1.2/1.3 it is 64meg.
    Is the java heap the amount of memory requested by the java process (from the os)
    invoked.If the allocation exceed in that process does the Jvm tells you dont have
    more memory.If you exceed the maximum then java will produce an out of memory exception. Keep in mind the following:
    -The maximum is not exact. The out of memory exception can be produced when less than 64 meg is used. This is due to the way garbage collection works. The subject is complicated and if you want to know more then search this forum for topics about the garbage collector.
    -Keep in mind that the java heap is not the same as how much memory the JVM will consume. So even if the maximum is 64 meg you might use an OS tool which says it is using more. Because the OS tool tells you the total memory being used which includes the JVM code, the executable heap and stack and the jvm stack and heap.
    Usually I run the application without specifying the limit
    and I believe a bad code can let the entire system hog,but if the java heap
    range is given only the java process will get held up and the other processes
    can run.Please correct the analysisBottlenecks are not only caused by memory contention. You can write a java app that uses very little memory but totally consumes the CPU and this will tend to slow the box. There are other possible bottle necks.

  • OpenSQL limit in Java

    Hi,
    I have been using OpenSQL but I'm unable to find how I can use the limit function to get only the results from from 1-10 and then from 11-20.
    In mysql I would have used the limit function, but either the syntax has changed or it works in a different way.
    How can I implement a limit functionality in the system .
    Daniel

    Daniel,
    I might be wrong here, but if I remember correctly, if you use OpenSQL your are limiting yourself to SQL 92 which does not contain a syntax to limit/to/first 10 your result set. As you do not need to fetch all results via JDBC this should not be a critical issue. You can limit the fetch size, but that is typically already defaulted to 10.
    Hope that helps,
    Christian

  • How do I increase the thread limit on Linux?

    OS: Linux (or Sun Linux)
    Kernel: 2.4.9-31enterprise
    Memory: 2GB
    CPUs: 2
    Java: 1.4.1_01
    I have a dual processor Cobalt LX50 and I am running
    into a thread limit with Java. No matter what I do
    with the Java JVM parameters (heap and stack), I
    cannot get any more than 949 threads. My "top" and "vmstat" output
    shows that I am no where near my memory capacity.
    Below is a simple Java program (28 lines long) I have
    used to test this limit. My question is simply how do
    I go about increasing this limit. Is there some kernel
    parameter I can set or maybe have to recompile into
    the kernel? My /proc/sys/kernel/threads-max is 16383.
    I do not believe my ulimit settings are the problem,
    but I will post them anyway. The problem also occurs
    on non-Cobalt (plain old PCs) uniprocessor machines
    maxxing at about 1018 threads. The other interesting thing is that when I run the same program through the Kaffe VM with -Xms64M and -Xmx512M I do not run into the thread limit problem. Does anyone know what I need to change to get my thread limit up? Also, rewriting the way the program uses threads is not an option.
    [root]# ulimit -a core file size (blocks) 0
    data seg size (kbytes) unlimited
    file size (blocks) unlimited
    max locked memory (kbytes) unlimited
    max memory size (kbytes) unlimited
    open files 1024
    pipe size (512 bytes) 8
    stack size (kbytes) 8192
    cpu time (seconds) unlimited
    max user processes 8191
    virtual memory (kbytes) unlimited
    /*******************************Sample java program
    testing thread
    limits***********************************************/
    import java.util.Timer;
    import java.util.TimerTask;
    public class Reminder {
    Timer timer;
    static int cnt;
    public Reminder(int seconds) {
    timer = new Timer();
    timer.schedule(new RemindTask(), seconds*1000);
    class RemindTask extends TimerTask {
    public void run() {
    System.out.println("Time's up!");
    timer.cancel(); //Terminate the timer thread
    public static void main(String args[]) {
    System.out.println("About to schedule task.");
    cnt = 0;
    while (true) {
    new Reminder(90);
    System.out.println("Thread #" + ++cnt + "
    scheduled.");

    Confer also:
    http://forum.java.sun.com/thread.jsp?forum=37&thread=358276

  • Getting no output from java.util.logging.FileHandler

    I am new to Java as is the company I work for, but we have just landed a contract that specifies J2EE as the platform, so here we are. :-) Please bear with me.
    I have been charged with determining our logging architecture and it looks like what is available in java.util.logging will do well (though we may use log4j). However, at this point I am just trying to get anything to work and not having much luck.
    We are using JSF on the front end and I have created a very simple JSF page to test logging. The relevant code is below and I hope will be self explanatory: This code is not meant to be efficient or anything. It is just a proof of concept.
        public String button1_action() {
            // User event code here...
            try {
                Logger l = java.util.logging.Logger.getLogger(Page1.class.getName());
                l.entering(Page1.class.getName(), "button1_action");
                l.info(this.textField1.getValue().toString());
                l.exiting(Page1.class.getName(), "button1_action");
                java.util.logging.Handler h = l.getHandlers()[0];
                h.flush();
            catch(Exception ex) {
                //I have tested this and we aren?t catching any errors.
                System.err.println(ex);
            return "";
        }My logger.properties files looks like this:
    handlers= java.util.logging.FileHandler
    .level= FINEST
    java.util.logging.FileHandler.pattern = c:/sun/logs/test-%u.log
    java.util.logging.FileHandler.limit = 50000
    java.util.logging.FileHandler.count = 1
    java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatterI have developed and tested this in Sun Studio Creator 2004Q2 What is happening is that I am getting three log files in c:/sun/logs
    test-0.log, test-1.log and test-2.log. The first two contain output from various sun components. (sun.rmi.transport for example). The third log remains empty. (zero length)
    I have also deployed the test app to a tomcat 5.0.28 server and get similar results. The only difference is I get only one two log files and the second one remains empty.
    Any assistance or suggestions as to what direction I should be taking would be appreciated.
    --Ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Do not use default logger as getLoggers[0] , but use your java.util.Logger.FileHandler and add filehandler object to log your fButtonActions and you do not need to mess with logger.properties too.

  • Java.lang.OutOfMemoryError,again and again....

    hi,
    my application run env is following :
    *1)java version "1.6.0_14" & je-3.3.82.jar*
    *2) je run properties:*
              envConfig.setAllowCreate(true);
              envConfig.setConfigParam("je.env.sharedLatches", "false");
              envConfig.setCacheSize(100 * 1024 * 1024);
              dbConfig.setAllowCreate(true);
              dbConfig.setDeferredWrite(true);
              dbConfig.setDuplicateComparator(PageDataComparator.class);
    *3)java -Xms1024m -Xmx1024m*
    *4) num #instances #bytes class name*
    12: 174568 6982720 com.sleepycat.je.tree.LN
    21: 3101 3249848 [Lcom.sleepycat.je.tree.Node;
    117: 3009 553656 com.sleepycat.je.tree.BIN
    176: 3181 203584 com.sleepycat.je.latch.SharedLatch
    196: 3025 96800 com.sleepycat.je.utilint.TinyHashSet
    224: 505 20200 com.sleepycat.je.cleaner.OffsetList$Segment
    229: 92 14720 com.sleepycat.je.tree.IN
    241: 64 10240 com.sleepycat.je.dbi.DatabaseImpl
    250: 159 7632 com.sleepycat.je.latch.LatchStats
    259: 159 6360 com.sleepycat.je.latch.Latch
    261: 64 6144 com.sleepycat.je.tree.Tree
    268: 16 4992 com.sleepycat.je.cleaner.Cleaner
    269: 16 4992 com.sleepycat.je.dbi.EnvironmentImpl
    270: 16 4736 com.sleepycat.je.log.FileManager
    273: 96 4608 com.sleepycat.je.cleaner.DbFileSummary
    280: 16 3968 com.sleepycat.je.evictor.PrivateEvictor
    284: 159 3816 com.sleepycat.je.latch.Latch$JEReentrantLock
    297: 57 3192 com.sleepycat.je.cleaner.FileSummary
    301: 16 3072 com.sleepycat.je.incomp.INCompressor
    305: 52 2912 com.sleepycat.je.tree.Tree$RootChildReference
    306: 52 2912 com.sleepycat.je.recovery.Checkpointer$CheckpointReference
    312: 16 2688 com.sleepycat.je.recovery.RecoveryInfo
    313: 16 2688 com.sleepycat.je.recovery.Checkpointer
    314: 48 2688 com.sleepycat.je.log.LogBuffer
    315: 16 2688 com.sleepycat.je.cleaner.FileProcessor
    317: 64 2560 com.sleepycat.je.cleaner.DbFileSummaryMap
    322: 19 2432 com.sleepycat.je.txn.BasicLocker
    323: 101 2424 com.sleepycat.je.dbi.DatabaseId
    327: 26 2288 com.sleepycat.je.cleaner.TrackedFileSummary
    330: 39 2184 com.sleepycat.je.config.IntConfigParam
    331: 16 2176 com.sleepycat.je.dbi.MemoryBudget
    340: 16 2048 com.sleepycat.je.txn.TxnManager
    341: 25 2000 com.sleepycat.je.tree.FileSummaryLN
    347: 33 1848 com.sleepycat.je.DatabaseConfig
    350: 16 1792 com.sleepycat.je.cleaner.FileSelector
    351: 32 1792 com.sleepycat.je.tree.NameLN
    352: 16 1792 com.sleepycat.je.recovery.CheckpointEnd
    353: 32 1792 com.sleepycat.je.tree.MapLN
    354: 27 1728 com.sleepycat.je.log.LogEntryType
    362: 64 1536 com.sleepycat.je.tree.TreeStats
    364: 38 1520 com.sleepycat.je.config.BooleanConfigParam
    370: 16 1408 com.sleepycat.je.log.SyncedLogManager
    371: 16 1408 com.sleepycat.je.Database
    381: 16 1280 com.sleepycat.je.log.TraceLogHandler
    382: 16 1280 com.sleepycat.je.log.FSyncManager
    383: 16 1280 com.sleepycat.je.log.LogBufferPool
    389: 17 1224 com.sleepycat.je.EnvironmentConfig
    391: 16 1152 com.sleepycat.je.cleaner.UtilizationProfile
    392: 16 1152 com.sleepycat.je.txn.SyncedLockManager
    397: 17 1088 com.sleepycat.je.recovery.Checkpointer$FlushStats
    403: 16 1024 com.sleepycat.je.Environment
    404: 16 1024 com.sleepycat.je.EnvironmentMutableConfig
    405: 16 1024 com.sleepycat.je.dbi.DbTree
    416: 19 912 com.sleepycat.je.log.FileManager$1
    418: 16 896 com.sleepycat.je.RunRecoveryException
    419: 16 896 com.sleepycat.je.cleaner.UtilizationTracker
    420: 16 896 com.sleepycat.je.config.LongConfigParam
    433: 25 800 com.sleepycat.je.cleaner.PackedOffsets
    435: 16 768 com.sleepycat.je.log.FileManager$LogEndFileDescriptor
    436: 16 768 com.sleepycat.je.cleaner.UtilizationProfile$FilesToMigrate
    437: 16 768 com.sleepycat.je.txn.LockImpl
    438: 16 768 com.sleepycat.je.dbi.INList
    441: 15 720 com.sleepycat.je.log.FileHandle
    448: 8 704 com.sleepycat.je.log.entry.LNLogEntry
    450: 17 680 com.sleepycat.je.TransactionConfig
    453: 16 640 com.sleepycat.je.dbi.NodeSequence
    455: 16 640 com.sleepycat.je.log.FSyncManager$FSyncGroup
    457: 16 640 com.sleepycat.je.PreloadConfig
    459: 16 640 com.sleepycat.je.dbi.MemoryBudget$PrivateTotals
    460: 16 640 com.sleepycat.je.log.FileManager$FileCache
    475: 16 512 [Lcom.sleepycat.je.latch.Latch;
    476: 16 512 com.sleepycat.je.utilint.TracerFormatter
    477: 16 512 com.sleepycat.je.txn.LockInfo
    479: 16 512 com.sleepycat.je.dbi.DbConfigManager
    483: 16 512 [Lcom.sleepycat.je.cleaner.FileProcessor;
    489: 19 456 com.sleepycat.je.CursorConfig
    499: 10 400 com.sleepycat.je.log.entry.SingleItemEntry
    504: 16 384 com.sleepycat.je.evictor.Evictor$EvictProfile
    515: 9 360 com.sleepycat.je.cleaner.OffsetList
    530: 5 320 [Lcom.sleepycat.je.txn.LockConflict;
    531: 5 320 [Lcom.sleepycat.je.txn.LockUpgrade;
    536: 2 296 [Lcom.sleepycat.je.log.LogEntryType;
    551: 4 256 com.sleepycat.je.log.entry.INLogEntry
    554: 6 240 com.sleepycat.je.txn.LockAttemptResult
    557: 6 240 com.sleepycat.je.config.ConfigParam
    562: 2 224 com.sleepycat.je.log.entry.NameLNLogEntry
    566: 7 224 com.sleepycat.je.txn.LockType
    572: 5 200 com.sleepycat.je.log.entry.DbOperationType
    578: 2 192 com.sleepycat.je.log.entry.DeletedDupLNLogEntry
    579: 8 192 com.sleepycat.je.txn.LockGrantType
    583: 6 192 com.sleepycat.je.txn.LockUpgrade
    585: 4 192 com.sleepycat.je.log.FileManager$FileMode
    612: 1 144 com.sleepycat.je.dbi.CursorImpl
    628: 4 128 com.sleepycat.je.dbi.CursorImpl$SearchMode
    629: 3 128 [Lcom.sleepycat.je.dbi.DbEnvState;
    632: 3 120 com.sleepycat.je.txn.LockResult
    635: 3 120 com.sleepycat.je.Durability
    636: 3 120 com.sleepycat.je.log.LogEntryType$Replicable
    639: 2 112 com.sleepycat.je.dbi.DatabaseImpl$HaltPreloadException
    656: 3 96 com.sleepycat.je.txn.ThinLockImpl
    657: 3 96 com.sleepycat.je.log.Provisional
    658: 4 96 com.sleepycat.je.OperationStatus
    659: 1 96 com.sleepycat.je.tree.INLogItem
    664: 4 96 com.sleepycat.je.LockMode
    667: 4 96 com.sleepycat.je.dbi.PutMode
    669: 3 96 com.sleepycat.je.CacheMode
    671: 3 96 com.sleepycat.je.Durability$SyncPolicy
    675: 3 96 com.sleepycat.je.Durability$ReplicaAckPolicy
    676: 4 96 com.sleepycat.je.dbi.DbEnvState
    679: 2 96 com.sleepycat.je.DatabaseEntry
    691: 1 80 com.sleepycat.je.log.LogItem
    699: 2 80 com.sleepycat.je.log.entry.BINDeltaLogEntry
    700: 2 80 com.sleepycat.je.log.LogEntryType$Txnal
    701: 2 80 com.sleepycat.je.log.LogEntryType$Marshall
    709: 3 72 com.sleepycat.je.Database$DbState
    717: 3 72 com.sleepycat.je.PreloadStatus
    723: 3 72 com.sleepycat.je.txn.LockConflict
    729: 1 64 com.sleepycat.je.cleaner.LocalUtilizationTracker
    737: 1 64 [Lcom.sleepycat.je.log.entry.DbOperationType;
    740: 2 64 com.sleepycat.je.log.ReplicationContext
    748: 1 64 [[Lcom.sleepycat.je.txn.LockConflict;
    750: 1 64 [[Lcom.sleepycat.je.txn.LockUpgrade;
    758: 1 56 com.sleepycat.je.log.LogEntryHeader
    761: 1 56 com.sleepycat.je.log.DbOpReplicationContext
    767: 1 56 [Lcom.sleepycat.je.log.FileManager$FileMode;
    777: 1 48 [Lcom.sleepycat.je.log.Provisional;
    779: 1 48 com.sleepycat.je.tree.INLogContext
    791: 1 48 com.sleepycat.je.tree.SplitRequiredException
    792: 1 48 com.sleepycat.je.tree.Tree$RelatchRequiredException
    797: 1 48 [Lcom.sleepycat.je.CacheMode;
    806: 1 48 com.sleepycat.je.cleaner.LNInfo
    807: 1 48 com.sleepycat.je.tree.TreeLocation
    809: 1 48 [Lcom.sleepycat.je.Durability$SyncPolicy;
    811: 1 48 com.sleepycat.je.recovery.DirtyINMap
    812: 1 48 [Lcom.sleepycat.je.Durability$ReplicaAckPolicy;
    814: 3 48 com.sleepycat.je.tree.Tree$SearchType
    821: 1 48 [Lcom.sleepycat.je.log.LogEntryType$Replicable;
    823: 1 48 com.sleepycat.je.dbi.RangeRestartException
    832: 1 40 com.sleepycat.je.log.LogContext
    851: 1 40 [Lcom.sleepycat.je.log.LogEntryType$Txnal;
    854: 1 40 [Lcom.sleepycat.je.log.LogEntryType$Marshall;
    864: 1 32 com.sleepycat.je.CheckpointConfig
    877: 1 32 [Lcom.sleepycat.je.cleaner.LNInfo;
    880: 1 32 com.sleepycat.je.tree.SearchResult
    881: 1 32 [Lcom.sleepycat.je.log.LogItem;
    890: 1 32 com.sleepycat.je.dbi.DbEnvPool
    960: 1 24 com.sleepycat.je.tree.Key$DumpType$1
    963: 1 24 com.sleepycat.je.tree.Key$DumpType$2
    964: 1 24 com.sleepycat.je.tree.BINBoundary
    965: 1 24 com.sleepycat.je.tree.Key$DumpType$3
    967: 1 24 com.sleepycat.je.tree.Key$DumpType$4
    *5) Error output*
    [java] Exception in thread "Thread-9" java.lang.OutOfMemoryError: GC overhead limit exceeded
    [java] at com.sleepycat.je.log.LogManager.log(LogManager.java:279)
    [java] at com.sleepycat.je.log.LogManager.log(LogManager.java:268)
    [java] at com.sleepycat.je.log.LogManager.log(LogManager.java:199)
    [java] at com.sleepycat.je.tree.LN.log(LN.java:524)
    [java] at com.sleepycat.je.tree.LN.log(LN.java:373)
    [java] at com.sleepycat.je.cleaner.Cleaner.migrateLN(Cleaner.java:1213)
    [java] at com.sleepycat.je.cleaner.Cleaner.lazyMigrateLNs(Cleaner.java:928)
    [java] at com.sleepycat.je.tree.BIN.beforeLog(BIN.java:1182)
    [java] at com.sleepycat.je.recovery.Checkpointer.logSiblings(Checkpointer.java:1263)
    [java] at com.sleepycat.je.recovery.Checkpointer.flushIN(Checkpointer.java:965)
    [java] at com.sleepycat.je.recovery.Checkpointer.flushIN(Checkpointer.java:1091)
    [java] at com.sleepycat.je.recovery.Checkpointer.flushDirtyNodes(Checkpointer.java:704)
    [java] at com.sleepycat.je.recovery.Checkpointer.syncDatabase(Checkpointer.java:599)
    [java] at com.sleepycat.je.dbi.DatabaseImpl.sync(DatabaseImpl.java:861)
    [java] at com.sleepycat.je.Database.sync(Database.java:428)
    *6.mem.bin --analysis*
    Problem Suspect 1
    16 instances of "com.sleepycat.je.dbi.EnvironmentImpl", loaded by "sun.misc.Launcher$AppClassLoader @ 0x2aaab6882a80" occupy 50,938,584 (51.10%) bytes.
    Problem Suspect 2
    2,359 instances of "com.sleepycat.je.tree.BIN", loaded by "sun.misc.Launcher$AppClassLoader @ 0x2aaab6882a80" occupy 42,783,504 (42.92%) bytes.

    Also perhaps notable: the kind of OOME here -- "GC overhead limit exceeded" -- is one of the OOMEs where the JVM isn't really out of heap memory. Rather, it's just decided it's spending too much time collecting garbage. So there might be an application issue creating garbage as fast as possible.
    A little info about this type of OOME for the parallel and concurrent collectors in J6 are here:
    http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html#par_gc.oom
    http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html#cms.oom
    Apparently this time-based check can be disabled (and I think I once saw an option for changing the percentage-of-time threshold without disabling it entirely, but the above links don't mention that option).
    - Gordon @ IA

  • How many number of lines of code Java File can have?

    Hi ALL
    Is there any limit on java source file code length?
    does more code (say more than 4000 line) impact on performace?
    Is there any recomendation on code length and file size?
    Thanks

    Hi ALL
    Is there any limit on java source file code length? There are some (VM) limitations but I have only hit that one when I had some generated code.
    does more code (say more than 4000 line) impact on
    performace?No, but you probably have a stupid design if you have 4000 lines in one file.
    Is there any recomendation on code length and file
    size?You should usually only have one top level clas per file, and you should try to have less than 1000 lines in one class.
    Kaj

  • Java 1.4 is HUGE!

    Just installed the 1.4 beta 2, and the JRE part of it is HUGE at some 38MB! In compressed form it is some massive 18MB! It is now an operating system!
    I think we have a new "Hello World" record here. What does this mean, do I need to distribute my software on a CD from now on? That is impossible for me!
    Sun, please explain how we are supposed to deploy our software through the Internet now. Do you know that most people still have modem or at the max ISDN? This means it would take around an hour to download only the basic runtime environment!
    And further, most people in the world pay for the time they are online. No way they want to download my software this way, unless it is something totally amazing which they wont know until they download it anyways, but they surely wont! And yes, Internet distribution is the only way that works for me and everyone else I know!
    Did I miss something here? I suppose they have debug info in the jar file that can be removed (I really hope so), but still? 18MB?? Even 10MB would be a total overkill! They surely cannot expect us to bundle this kind of huge JRE with our code? Can they? Are they totally insane?

    Who cares? In the Java world money is to be
    made on the server side, in enterprise
    software, where millions of dollars are spent and
    hosts of consultants are there to deploy the software
    on the clients' sites. Nobody in that world cares if a
    JDK is 10 Mb or 100Mb.
    If you wrote a dinky little applet for another chat
    room implementation maybe you should realise that this
    is not all the direction that Java in going in. Go
    back to [D]HTML/Javascript. Java is not for the client
    side.
    Vlad.Vlad: I understand what you are saying. Keep in mind, I am with you on server side.
    But it is pretty ignorant to say java ONLY makes money on the server side. More ignorant is to relate "enterprise"
    to server side apps. Just because J2EE has term "enterprise" in it and you can write server side code using EJB/Servlet/JSP doesn't mean that's where one should stop thinking.
    Last ignorance is: Applets are the limit of Java on desktop. You wrote a little applet and that's it. Fine. So that's all you think everyone should do? Stop after writing "a dinky little chat application"
    Coming back to enterprise topic.
    Who says enterprises do NOT
    need desktop applications.
    Billions of dollars are to be made on the desktop front as well. Just because you got all your desktop tools with a free linux distribution does not mean that everybody will do the same, in particular, enterprises. Windows users, just because all the desktop apps you need came from that windows CD you copied from work doesn not mean someone didn't pay for it. Ok, what developers need could be free/open source/pirated.
    But an enterprise needs business applications. They need some kind of editor, some presentation program, some number crunching program (SAS products for the web? charts on the web? sure. they are possible, tell it to a big corporation to switch 20,000 employees/auditors from their quick response desktop app to a web based app), some graphics program (don't tell me you are going to create Photoshop with an HTML front end so it can run on the server side). etc.
    Now let me tell you where you can make money. Write a Lotus Notes like app in Java. Lotus makes millions and millions from that "not so dinky" desktop app. Write a software like SAS prodcuts in Java. Millions there as well. There already are office suites in Java. People did write those apps. Even Java programmers are switching from using Rational Rose to TogetherJ which is a desktop Java app.
    In any case, Sun spends a lot of money on Swing. There is a reason. And people can write good desktop apps if they know how to. Problem posed by the original poster is that JRE is bloated, it is a legitimate complaint because most of the world has only written "dinky" things and they cannnot understand why they need 18 MB of runtime in their distribution.
    Swing is still visibly slower than native GUIs, unless code tweaked/optimized. All complaints are legit.
    But:
    I think that desktop applications are equally required by enterprises {unquote}.

  • Plz help , getting error in my java code

    Can any one tell the reason for this error:
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    is there any size limit for java classes that I am using in my code?
    My code Looks like:
         FileChannel in = null, out = null;
         try {
         in = new FileInputStream(sourceLocation).getChannel();
    System.out.println(in.size() +"RptPageBreak rtn: b 4 read file into buffer, source=" + sourceLocation);
    // read the file into buffer
    // System.out.println("-1 " +in.size() );
    MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, in.size());
         //System.out.println("RptPageBreak rtn: AFTER read file into buffer" );
    System.out.println("1: "+ buf.capacity()+" " +in.size() );
    // CharBuffer cb;
                   try {
                        cb = Charset.forName ("UTF-8").decode (buf);
                   } catch (Exception ex) {
                        System.out.println("2:"+ ex.getMessage());
                        ex.printStackTrace();
    System.out.println("2");
    String lines[] = Pattern.compile ("\n").split (cb, 0);
         //System.out.println("RptPageBreak rtn: lines.len=" + lines.length);
         Writer writer = new FileWriter (targetLocation);
         System.out.println("3");
         for (int i = 0, n = lines.length; i < n; i++) {
              // also compare if starts with a CRLF
         if ( ( lines.startsWith("\r\n" + rpt_headg_id) == true ) ||
                   ( lines[i].startsWith("\f" + rpt_headg_id) == true ) ||
    ( lines[i].startsWith(rpt_headg_id) == true ) )
    //if ( lines[i].contains(rpt_headg_id) == true )
         //System.out.println("RptPageBreak rtn: found headg in if loop " + rpt_headg_id );
    writer.write ("1");
    else {
         writer.write (" "); // detail lines shift over 1 by addg a space
    writer.write (lines[i]);
    writer.write ('\n');
    //System.out.println("RptPageBreak rtn: lines[i]=" + i + ' ' + lines[i]);
    writer.close ();
    }catch(Exception e)
         System.out.println("RptPageBreak rtn: Catch Exception: " + e.getMessage() );
         status=false;
    e.printStackTrace();
    finally {
         try {
    if (in != null) in.close();
    if (out != null) out.close();
    status=true;
    catch(Exception e)
         System.out.println("RptPageBreak rtn: Finally-Catch Exception: " + e.getMessage() );
         status=false;
    e.printStackTrace();

    It has nothing to do with classes. It is that you are reading to much info into memory at one time. If you are only going to cycle through the input line for line, anyway, then why don't you simply read the file (or whatever) a line at a time and process it as you read it, rather than loading the entire thing at once?

  • Dynamic java logging properties file

    Hello,
    I am looking for a dynamic way to set a property in a java logging properties file.
    For example something like this:
    java.util.logging.FileHandler.pattern = ${log.dir}/logfile%u.log
    ..where log.dir is a system property. But this does not work. Any other way to do it?
    Thanks in advance,
    Rohnny

    This pattern doesn't work ? here is the content of my
    logging.properties file.
    java.util.logging.FileHandler.pattern = LOGFILE.log
    java.util.logging.FileHandler.limit = 50000
    java.util.logging.FileHandler.count = 1
    java.util.logging.FileHandler.formatter =
    java.util.logging.SimpleFormatter
    FIRST_LOGGER.Handler = java.util.logging.FileHandler
    FIRST_LOGGER.level = ALL
    SECOND_LOGGER.Handler =
    java.util.logging.FileHandler
    SECOND_LOGGER.level = ALLIt seems like you're not thoroughly reading the spec on this stuff.
    I don't think ".Handler" is even a valid property on a logger.
    Loggers aren't typically initialized with a complex configuration out of a configuration file...unless you write your own custom format. For instance, FileHandler is a class, so when you define java.util.logging.FileHandler.pattern in the config file, you're defining it for every default instance of FileHandler...so naturally both your loggers that use FileHandlers will write to the same file.
    I've never done this before, but here's what I came up with after reading the spec:
    1) define 1 subclass of FileHandler for each file you want to write to... let's call them FileHandlerA and FileHandlerB. All they have to do is extend FileHandler, nothing else.
    2) define the patterns for each subclass in the config file. You can also define any other properties you want for each handler, such as .level, .limit, .count, etc.
    mypackage.myhandlers.FileHandlerA.pattern = LogFile-A.log
    mypackage.myhandlers.FileHandlerB.pattern = LogFile-B.log
    // ... more config here
    3) define the loggers in the config file and specify the handlers to use on each:
    FIRST_LOGGER.handlers = mypackage.myhandlers.FileHandlerA
    SECOND_LOGGER.handlers = mypackage.myhandlers.FileHandlerB
    4) create your Loggers in your code:
    Logger firstLog = Logger.getLogger("FIRST_LOGGER");
    Logger secondLog = Logger.getLogger("SECOND_LOGGER");
    Good luck.

  • Java.util.logging question

    'Lo all -
    I'm new to Java, so bear with me on this question - I'm sure it has a simple answer.
    I am using the following code to create a new Logger object:
    public class TAGLogging {
        private Logger oLog;
        private FileHandler oLogFile;
        private String sLoggingFolder = "AppLogs";
        private String sFormattedDateTime = String.format("%1$tY%1$tm%1$td_%1$tH%1$tM%1$tS",Calendar.getInstance());
        private String sCallingClass = new Throwable().fillInStackTrace().getStackTrace()[1].getClassName();
        private String sCallingMethod = new Throwable().fillInStackTrace().getStackTrace()[1].getMethodName();
        /** Constructors */
        public TAGLogging(String sLogFileName) throws IOException {
            this.initialSetup(sLogFileName);
        public TAGLogging() throws IOException {
            String sLogFileName = sLoggingFolder + File.separator + sFormattedDateTime + ".xml";
            this.initialSetup(sLogFileName);
        /** Methods */
        private void initialSetup(String logFileName) throws IOException {
            oLogFile = new FileHandler(logFileName);
            oLog = Logger.getLogger(sCallingClass);
            oLog.addHandler(oLogFile);      
            oLog.setLevel(Level.ALL);
        }Everything is being logged correctly to the /AppLogs/yyyymmdd_HHMMSS.xml file. The problem is that there is another file that is being created in my home directory, which incidentally, is not where the program is located. The name, java01.log, matches the default logging.properties file set up, but I have removed all that and changed the file to the following (minus all the comments):
    handlers= java.util.logging.FileHandler
    .level= INFO
    java.util.logging.FileHandler.level = ALL
    java.util.logging.FileHandler.limit = 50000
    java.util.logging.FileHandler.count = 1
    java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
    java.util.logging.ConsoleHandler.level = INFO
    java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
    The java01.log file contains the exact same contents as the file I am purposely logging to, the AppLogs/yyyymmd_HHMMSS.xml one.
    Does anyone have any clue what is causing this file to get created, and if so, how do I stop it?
    Message was edited by:
    malakh

    Man, I REALLY hate to do this, but it looks like I may be forced to work around it instead of fixing the issue. I'll have to add some code to manually remove the java01.log file when it's done writing to it.
    Navy - Turns out that Log4j is pretty much the same thing as java.util.logging, except on steroids. It is almost identical syntactically, just has more options and more flexibility than JUL.

  • Enabling java.util.logging for Toplink

    JDeveloper 10.1.3.0.4 Build 3673 running Embedded OC4J (jdk1.5.0_02).
    I'm trying to get Toplink to log to a custom handler (a la java.util.logging) while running Embedded OC4J, but nothing I've tried works.
    If I use the java.util.logging.LogManager to loop through and print out all of the existing loggers, none of the 145 listed in the Embedded OC4J environment mention anything about toplink. So presumably Toplink is not running in "java" logging mode. I'm not using toplink workbench which seems to have a UI checkbox to enable java logging, and I haven't found a way to turn it on using JDeveloper. I've tried using the system property -Dtoplink.log.destination=JAVA (no effect) and adding my handler to j2ee-logging.xml (couldn't find my custom logging handler class, and won't help anyway if toplink isn't using java.util.logging), and various attempts at hacking sessions.xml with using log-type and java-log elements (I couldn't get them right--xml parse errors).
    What do I need to do to get Toplink to log to a custom handler?
    TIA,
    Clark

    Hi Clark,
    You can use either java or server log when running an application in OC4J.
    1 When you run a CMP application, use system property (e.g. Dtoplink.log.destination=JAVA)
    2 When you run a non CMP server application, use the logging tag in sessions.xml (e.g. <logging xsi:type="server-log"/>)
    You have the following options to get TopLink to log to a custom handler
    1 If you want to do the entire configuration from logging.properties, remove all handlers/loggers declarations from j2ee-logging.xml and in that case all configuration will be from logging.properties
    2 Use a combination of j2ee-logging.xml and logging.properties. You can define certain attributes in j2ee-logging.xml. They are "name", "class", "level", "errorManager", "filter", "formatter" and "encoding", and they correspond to the attributes of java.util.logging.Handler. Attributes in subclasses of Handler are not supported. All other properties for the handler are defined in logging.properties. j2ee-logging.xml is processed on top of logging.properties, which means j2ee-logging.xml takes the precedence for certain attributes/properties. Take FileHandler for an example,
    j2ee-logging.xml:
         <log_handlers>
         <log_handler name='my-handler' class='java.util.logging.FileHandler'
              formatter='java.util.logging.SimpleFormatter' level='INFO'/>
         </log_handlers>
    logging.properties:
         java.util.logging.FileHandler.pattern = %h/java%u.log
         java.util.logging.FileHandler.limit = 10000
         java.util.logging.FileHandler.count = 2
    If there are no properties defined in logging.properties, it will use its default values, which are documented in the FileHandler javadoc.
    Shannon

  • Defining a formatter for java logging

    I'm trying to define my own Formatter object to be used for file logging. For some reason, the code does not want to recognize this. Here is the property file snippet:
    # default file output is in user's home directory.
    java.util.logging.FileHandler.pattern = c:/logs/etc.
    java.util.logging.FileHandler.limit = 500
    java.util.logging.FileHandler.count = 3
    java.util.logging.FileHandler.formatter= org.frb.ny.log.MyFormatter
    At runtime, logging decides to use XMLFormatter....
    Is this suppossed to work? When I do this programatically it works fine.
    Thank you

    You must use the -Xbootclasspath/a: java launcher option so that the Formatter subclass (or any other class referenced in a logger configuration file for that matter) in on the bootstrap classpath

  • Can java.util.logging.SimpleFormatter log stack trace?

    can java.util.logging.SimpleFormatter log stack trace? I hope I don't have to write a custom formatter.
    -yc

    right, it does, the code I am modifying prints regular log msg at LEVEL.SEVERE, that's why it doesn't have any stack trace.
    By the way, I am using file name pattern, aName.log%g, why it the most current log is aName.log.0, rather than just aName.log. In the conf file, I have,
    mypackage.myclass.logfile.name=/.../aName.log.%g
    java.util.logging.FileHandler.limit=60000
    java.util.logging.FileHandler.count=3
    java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
    Thanks.
    Message was edited by:
    javalatte1

  • Using an ADM to disable Java

    I am trying to limit the Java functionality within Firefox. I have installed the GPO and set Java to be disabled. I have an entry in the registry under HLM\Software\policies\Firefox That appear to have Java disabled, but the plugin still works. I am running Firefox version 16.0.2

    As far as I can determine you need to actually set the registry key, the property in the MSI doesn't appear to make any difference.
    HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Update\Policy\EnableJavaUpdate
    set it to dword:00000000
    I'm not sure if setting this in the MSI will work either since I haven't tested it, but the easier way is to do it in the GPO - this way you don't need to keep doing it in each future MST you create.
    This key will completely remove the update tab from the Java applet in the control panel so you won't even be able to do a manual update using this applet.
    There are other keys you can investigate to disable auto updates without completely disabling the mechanism.

Maybe you are looking for

  • Material cost estimate with quantity structure (tcode: CK11N)

    Hey dear friends. I donu2019t know in which forum I should put my question above. In fact, Iu2019m new to SAP PM module. Iu2019m trying to create material cost estimate with quantity structure (tcode: CK11N) for a material u201CXu201D. This material

  • Line chart in jsp

    Hai, i want to generate a line chart in jsp. can you plz help on this. plz dont suggest me any third party tools. Thanks in advance.

  • Dynamic Table control with context nodes and attributes?

    Hi all I have node and attributes in context. i want to create table dynamically using this node and attributes, can anyone give code how to do this??? Thanks Madhan.

  • Add SharePoint 2013 On-Premise to Add a Place in Office 2013

    We are in the process of rolling out SharePoint 2013 on-premise to all users in our organization. As part the roll-out we are also upgrading users to Office 2013. Unfortunately, we have difficulty explaining to users how to Save As to SharePoint the

  • Copying files that are updated.

    I wanted to make a program that copies files from a directory (and subdirectories) to another location. So let's say I have a folder in C:\myfolder . In this folder there is another folder (myfolder2) and some type of file(s) (.txt .docx etc.). In my