trivial question, type[] name vs type name[], quicktime messing my comp

Hello ppl.
Forgive me for asking such a noob question, but what is the difference between defining arrays:
“String[] var” and “String var[]” ? I was going crazy for an hour becouse of this…

I wanted to test drawing swing components and tried to made simplest JFrame like this:


import javax.swing.JFrame;

public class Menu extends JFrame {
	
	public Menu() {
		super("Menu test za Viktoirje");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
	    setVisible(true);
	}
	
	public static void main(String args[]) {
		new Menu();
	}
}

…it will compile but when I start it it complains it can’t find main class… I stared and stared and tried everything I can think of (console, classpaths…), nothing! I’ve looked at main method from my game… it’s identical. Finnaly hour later I created new class with eclipse with automaticly generated main and I saw that difference is what I wrote at top of post, array declaration. It works. I thought there’s no difference between 2 declarations…
Now I wonder, why the hell my huge game project works just fine with it and this little piece of sh** complains about not finding main??

String args[]
String []args
String[] args
String[]args (I use this one)

All works and all is the same. This however…

[]String args

doesnt work.

:slight_smile:
somebody please try to compile and run the code I gave then :slight_smile:
I’ve tried at least 30 times, double checking everything and making sure it is that code that I’m trying to run.

The code is fine.
It compiles fine.

yes it compiles fine, but have you run it and got the actual frame?

Edit: ok sorry all, I tried it on other computer and works :frowning: … something is wrong with my JRE or something :frowning:
mod can delete this thread, except that my software is screwed up nobody learned anything anyway

[quote=“Kova,post:5,topic:27077”]
sigh

java -cp . Menu

If you’ve installed something like Quicktime, it’s probably screwing up your classpath. For a more permanent solution, you can track down the Environment Variables in the System Settings. Make sure you DELETE all instances of CLASSPATH from the env vars. Do a simple reboot and you should find that you won’t need to use the “-cp” syntax.

damn it, I installed QuickTime just day before… I’m gonna uninstall and delete it so hard that best data recovery experts won’t find it ever again. Tnx jbanes. All I need was to see a single movie, and to install it you have to install iTunes also… so far no more .mov files for me, no matter how good they are.
Tnx a lot jbanes.

That won’t fix your problem. Just leave iTunes installed, right click on “My Computer”, go to “Properties”, select “Advanced”, click on “Environment Variables”, and delete “CLASSPATH” from both boxes. That will fix your problem. This is especially good to keep in mind because Quicktime is FAAAAAAR from the only program that will screw with your Java classpath.

right click on “My Computer”, go to “Properties”

+ :wink:

Btw there is also Quicktime Alternative, which isnt that much of a pain in the rear.

Why in the name of all things unholy does Quicktime mess with the classpath? :o

After uninstalling quicttime I don’t have classpath variable anymore… but some (or all) problem remains. Now all my exceptions look like this:

Exception in thread “main” java.lang.NullPointerException
at viktorije.Viktorije.(Unknown Source)
at viktorije.Viktorije.main(Unknown Source)

…instead of filename and line number I get unknown source, I think it’s related to quicktime screwing my computer. Any suggestions about this?

That’s your compiler settings, not QT. You need to leave the debugging info ON if you want line numbers. Otherwise they’ll get stripped out. If the program isn’t yours, the author probably did this to reduce the size of his code.

Stop worrying about Quicktime. It didn’t do anything major to your computer. All it did was add a classpath entry so that you could use QTJava. Now that the classpath entry is gone, its influence has dissapated. The remainder is all about educating yourself. In fact, you’d do well to learn all about what the ClassPath is, and how it works.

eh sorry… I got really mad at quicktime, it has taken me hours of time and my nerves… Those line numbers, it’s my fault, when I tried to fix the situation while I had QT installed I’ve tried to change everything in hope of solution… this part I forgot to turn on after.

[quote=“jbanes,post:12,topic:27077”]

Ah, silly me, I thought this was Quicktime the player, not some kind of API for it. :-[

[quote=“Orangy Tang,post:14,topic:27077”]
The API is bundled with the player. So it’s sort of both. :slight_smile:

[quote=“jbanes,post:15,topic:27077”]

Yeah, that part Apple got right… if you use Quicktime for Java you can just say to users “you need quicktime” and your Java app is supposed to “just work”.
But sadly there is no safe place to install the QT4J jars on Windows such that it is included in the classpath and will survive updates to the JRE. (Unlike Mac OS X where Apple put some thought into the classpath and provided a global extensions folder and a per-user extensions folder.)
…So they go and bugger up the classpath variable. You would think that they would fix it to keep ‘.’ in the classpath at least.