Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Terminal java compile/command issues

Basically every time I start my computer or don't use terminal for a short period of time it takes around two minutes to run a java compile/run command, as far as I can tell all other non java terminal commands are fine. After the first two minute wait my terminal returns to normal, and compiling/running programs takes a few seconds at most. This is extremely annoying as you can imagine! I would really appreciate it if someone could help me out, and thanks for lookin!

MacBook Pro, Mac OS X (10.7.5)

Posted on Feb 21, 2013 10:45 PM

Reply
14 replies

Feb 22, 2013 6:51 PM in response to lpdsss

I've no idea if there's anything to be done. I'm speculating as to the cause. It could be that after the first compilation, there are active caches that make subsequent compilations run faster. It could be caching in the JVM. It could be simply that the OS still has the necessary resources in "inactive" memory and is able to access them immediately for susequent compilations/runs...


But since I have no idea what you are compiling, or what command-line arguments you are using, I wouldn't even begin to guess.


If it's something like a caching isue, however, there's probably nothing you can easily do (except maybe move to an IDE).


I suppose for a start you could try compiling with the -verbose option and see what the compiler is actualy doing...

Feb 22, 2013 7:23 PM in response to lpdsss

I don't know if this will help, but when it's working fine the -verbose command prints out:


Alans-MacBook-Pro:compsciprograms alanyeung$ javac Scrabble.java -verbose

[parsing started Scrabble.java]

[parsing completed 9ms]

[search path for source files: .]

[search path for class files: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar,/S ystem/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar,/S ystem/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framewor k/Resources/Java/JavaRuntimeSupport.jar,/System/Library/Java/JavaVirtualMachines /1.6.0.jdk/Contents/Classes/ui.jar,/System/Library/Java/JavaVirtualMachines/1.6. 0.jdk/Contents/Classes/laf.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jd k/Contents/Classes/sunrsasign.jar,/System/Library/Java/JavaVirtualMachines/1.6.0 .jdk/Contents/Classes/jsse.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jd k/Contents/Classes/jce.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Co ntents/Classes/charsets.jar,/System/Library/Java/Extensions/AppleScriptEngine.ja r,/System/Library/Java/Extensions/dns_sd.jar,/System/Library/Java/Extensions/j3d audio.jar,/System/Library/Java/Extensions/j3dcore.jar,/System/Library/Java/Exten sions/j3dutils.jar,/System/Library/Java/Extensions/jai_codec.jar,/System/Library /Java/Extensions/jai_core.jar,/System/Library/Java/Extensions/mlibwrapper_jai.ja r,/System/Library/Java/Extensions/MRJToolkit.jar,/System/Library/Java/Extensions /QTJava.zip,/System/Library/Java/Extensions/vecmath.jar,/System/Library/Java/Jav aVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar,/System/Libr ary/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/dnsns.jar,/System/L ibrary/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar,/ System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunjce_p rovider.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib /ext/sunpkcs11.jar,.]

[loading java/util/ArrayList.class(java/util:ArrayList.class)]

[loading java/util/Scanner.class(java/util:Scanner.class)]

[loading java/lang/Object.class(java/lang:Object.class)]

[loading java/lang/String.class(java/lang:String.class)]

[loading ./Stack.class]

[loading java/lang/Character.class(java/lang:Character.class)]

[checking Scrabble]

[loading java/util/Collection.class(java/util:Collection.class)]

[loading java/util/AbstractList.class(java/util:AbstractList.class)]

[loading java/util/AbstractCollection.class(java/util:AbstractCollection.class)]

Scrabble.java:29: missing return statement

}

^

[total 375ms]


I will attempt the command again when the terminal again when the terminal (or JVM) is slow/lagging. Does anyone have any idea what the issue is from this printout?

Feb 23, 2013 7:32 AM in response to lpdsss

This is what it says when the terminal is lagging:


Alans-MacBook-Pro:compsciprograms alanyeung$ javac Queue.java -verbose

[parsing started Queue.java]

[parsing completed 45ms]

[search path for source files: .]

[search path for class files: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar,/S ystem/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar,/S ystem/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framewor k/Resources/Java/JavaRuntimeSupport.jar,/System/Library/Java/JavaVirtualMachines /1.6.0.jdk/Contents/Classes/ui.jar,/System/Library/Java/JavaVirtualMachines/1.6. 0.jdk/Contents/Classes/laf.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jd k/Contents/Classes/sunrsasign.jar,/System/Library/Java/JavaVirtualMachines/1.6.0 .jdk/Contents/Classes/jsse.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jd k/Contents/Classes/jce.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Co ntents/Classes/charsets.jar,/System/Library/Java/Extensions/AppleScriptEngine.ja r,/System/Library/Java/Extensions/dns_sd.jar,/System/Library/Java/Extensions/j3d audio.jar,/System/Library/Java/Extensions/j3dcore.jar,/System/Library/Java/Exten sions/j3dutils.jar,/System/Library/Java/Extensions/jai_codec.jar,/System/Library /Java/Extensions/jai_core.jar,/System/Library/Java/Extensions/mlibwrapper_jai.ja r,/System/Library/Java/Extensions/MRJToolkit.jar,/System/Library/Java/Extensions /QTJava.zip,/System/Library/Java/Extensions/vecmath.jar,/System/Library/Java/Jav aVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar,/System/Libr ary/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/dnsns.jar,/System/L ibrary/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar,/ System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunjce_p rovider.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib /ext/sunpkcs11.jar,.]

[loading ./LinkedList.class]

[loading java/lang/Object.class(java/lang:Object.class)]

[loading java/lang/Throwable.class(java/lang:Throwable.class)]

[loading java/lang/String.class(java/lang:String.class)]

[checking Queue]

[loading ./ListNode.class]

[loading java/lang/System.class(java/lang:System.class)]

[loading java/io/PrintStream.class(java/io:PrintStream.class)]

[loading java/io/FilterOutputStream.class(java/io:FilterOutputStream.class)]

[loading java/io/OutputStream.class(java/io:OutputStream.class)]

[wrote Queue.class]

[total 708ms]


can anyone offer me any advice on what to do?

Feb 23, 2013 2:40 PM in response to lpdsss

Are you using the default Apple-provided Java 6 JDK? It's obsolete, and more importantly for you javac was redesigned in Java 7 (around mid-2010) to reduce the number of fork-exec calls required to start the JVM (which is where all the expense is incurred).


I suggest that you update to the latest Java 7 JDK (the default updates only update the web plugin JRE): http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.h tml.


Then try again and see what happens.

Feb 23, 2013 9:23 PM in response to lpdsss

I have updated but I believe the problem is still occuring. I ran the -verbose command again and got this:


Alans-MacBook-Pro:compsciprograms alanyeung$ java Tester -verbose

The position is not within the range of the node count!

7

-1

3

2

Expected: 8, -1, 3, 3

NODE: -1

NODE: 0

NODE: 1

NODE: 2

NODE: 3

NODE: 4

NODE: 3

Alans-MacBook-Pro:compsciprograms alanyeung$ javac LinkedList.java

Alans-MacBook-Pro:compsciprograms alanyeung$ javac LinkedList.java -verbose

[parsing started RegularFileObject[LinkedList.java]]

[parsing completed 25ms]

[search path for source files: .]

[search path for class files: /Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/jre/lib/resourc es.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/jre/lib/r t.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/jre/lib/su nrsasign.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/jre /lib/jsse.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/jr e/lib/jce.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/jr e/lib/charsets.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Ho me/jre/lib/jfr.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Ho me/jre/lib/JObjC.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/ Home/jre/classes,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home /jre/lib/ext/dnsns.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Content s/Home/jre/lib/ext/localedata.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_15. jdk/Contents/Home/jre/lib/ext/sunec.jar,/Library/Java/JavaVirtualMachines/jdk1.7 .0_15.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar,/Library/Java/JavaVirtua lMachines/jdk1.7.0_15.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar,/Library/Java/ JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/jre/lib/ext/zipfs.jar,/System/ Library/Java/Extensions/AppleScriptEngine.jar,/System/Library/Java/Extensions/dn s_sd.jar,/System/Library/Java/Extensions/j3daudio.jar,/System/Library/Java/Exten sions/j3dcore.jar,/System/Library/Java/Extensions/j3dutils.jar,/System/Library/J ava/Extensions/jai_codec.jar,/System/Library/Java/Extensions/jai_core.jar,/Syste m/Library/Java/Extensions/mlibwrapper_jai.jar,/System/Library/Java/Extensions/MR JToolkit.jar,/System/Library/Java/Extensions/QTJava.zip,/System/Library/Java/Ext ensions/vecmath.jar,.]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)]]

[loading RegularFileObject[./ListNode.class]]

[checking LinkedList]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Throwable.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/AutoCloseable.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/String.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/System.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/io/PrintStream.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/io/FilterOutputStream.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/io/OutputStream.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/StringBuilder.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/CharSequence.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/io/Serializable.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Comparable.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/AbstractStringBuilder.class)]]

[loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Conten ts/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/StringBuffer.class)]]

[wrote RegularFileObject[LinkedList.class]]

[total 70021ms]


This one shows a better extimate of my wait time. Does anyone have any ideas that they could offer me?

Feb 24, 2013 6:18 PM in response to lpdsss

Well, it's actually quite difficult to evaluate your results because you never use the same file for both your "fast" and "slow" tests. And in both cases it appears that your "fast" test involves an aborted compilation due to an error or failed test...It's also impossible to figure out what exactly you are compiling. Is it simply a single java file, or are you playing with some kind of manifest file...?


You could try passing the option -XDignore.symbol.file on the command line. That would cause the ct.sym file to be ignored and the compiler to link directly against the contents of rt.jar. I have no idea if that will solve your problem, make it worse or just do nothing.


You could also, as I suggested before, try moving to an IDE that would shield you from having to try and figure out command line minutae for javac. Eclipse is quite good.

Feb 24, 2013 7:44 PM in response to lpdsss

Well, it's unlikely to be anything fundmentally wrong. Bad configuration, maybe. Poor programming practices, perhaps (do you by chance do things like import java.util.* instead of the specific classes you need?).


An IDE can shield you from most of that because they maintain their own symbol tables for your projects so that they can do things like offer code completion...on the straight command line, everybody's warts get exposed really quickly.

Terminal java compile/command issues

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.