Skip to content

How to build jars from IntelliJ properly?

I have a project that contains a single module, and some dependencies. I’d like to create a jar, in a separate directory, that contains the compiled module. In addition, I’d like to have the dependencies present beside my module. No matter how I twist IntelliJ’s “build jar” proce…

Java Object Method Stack Frame Parameters

So in java, say you have a non-static method ‘bar()’ in an class ‘Foo’. Say then that you call this method like so: Now the stack frame for the call includes the integer parameter, as well as a ‘this’ parameter to be used as an internal reference to the object. What other i…

How can I get the current stack trace in Java?

How do I get the current stack trace in Java, like how in .NET you can do Environment.StackTrace? I found Thread.dumpStack() but it is not what I want – I want to get the stack trace back, not print it out. Answer You can use Thread.currentThread().getStackTrace(). That returns an array of StackTraceEle…

Can I pass parameters by reference in Java?

I’d like semantics similar to C#’s ref keyword. Answer Java is confusing because everything is passed by value. However for a parameter of reference type (i.e. not a parameter of primitive type) it is the reference itself which is passed by value, hence it appears to be pass-by-reference (and peop…

Java Timer

I’m trying to use a timer to schedule a recurring event in an application. However, I want to be able to adjust the period at which the event fires in real time (according to the users input). For example: I then start a new instance of this class and call its set period function. However, when I do tha…

.class vs .java

What’s the difference between a .class file and a .java file? I am trying to get my applet to work but currently I can only run it in Eclipse, I can’t yet embed in HTML. Thanks **Edit: How to compile with JVM then? Answer A .class file is a compiled .java file. .java is all text and is human reada…