Getting jar to work on Vista

Started by fireside, July 28, 2008, 04:44:07 PM

Previous topic - Next topic

fireside

I have Vista and when I type "java" anywhere on the command line, I get the java help file.  But when I type "jar", it says unrecognized command.  Does anyone know how to fix that?
click here->Fireside 7 Games<-

fireside

Never mind, I found it on Google.  I just couldn't think of how to search for it at first.
click here->Fireside 7 Games<-

fireside

#2
I'm stumped here, maybe someone can help me out.  I have an applet that works in applet viewer, but when I try to use it outside with an html file, it doesn't work.

I can use the directories and class files; org/me/hello/WebPlayer.class; models/gear and models/box.jpg

In the html with:
<APPLET codebase="." code="org/me/hello/WebPlayer.class"  width=400 height=300 archive = "jpct.jar"></APPLET>

and it works without the applet viewer.

But when I try to use the netbeans jar or a jar that I create with models and org and do this:
<APPLET codebase="." code="org/me/hello/WebPlayer.class"  width=400 height=300 archive = "HelloApplet.jar,jpct.jar"></APPLET>

It starts to load and then stops leaving a black box.  I think it's not finding the model files.  I know the model files are in there because I used jar cf.
click here->Fireside 7 Games<-

Melssj5

Check the console to get the exceotions and post them.

If you got a black square is becausse the applet is loaded and jpct is running but if you cant see anything it may be due to the applet cant load the textures or the models. Post the exceptions to help us discover ehat is happening, the most probably is that your resource files (maps and textures) are inside the jar and then the applets cant find them.

Post the exceptions and lets see.

The console appears on the system tray in windows.
Nada por ahora

fireside

#4
It says applet org/me/hello/WebPlayer started


The black screen is what the buffer is set to clear, so it has to be at least getting that far, which means it's loading jpct and my class.
click here->Fireside 7 Games<-

Melssj5

there is nothing else on the console than:

applet org/me/hello/WebPlayer started????

is the only one line?

loading the models and materials makes a lot of prints on the console. it makes me think that the code is never loading the map or the textures. Post the full console please.
Nada por ahora

paulscode

This probably won't help you much, but I thought I would add my two-cents worth :D.

If it seems that one or more of your resources are not getting loaded, I was trying to think of what kind of things might cause problems wherever you load your resources.

If you are loading resources using a file stream directly from a physical directory, be sure to use the "\\" directory divider if the files are local to a Microsoft OS, but "/" if the files are on a Linux OS.

If you are loading resources the other way, with one of the "getResource" methods (which it looks like that is what you are probably doing here), use "/" for sub-directories and print out a message when an exception gets caught.  For example:

try
{
    java.io.InputStream myFile = getClass().getClassLoader().getResourceAsStream( "models/box.jpg" );
}
catch( IOException e )
{
    System.out.println( "Error loading resource file models/box.jpg" );
}


The only other advice I can think of is to temporarily make your applet as verbose as possible.  Print out a message for each line, and display the contents of varriables when possible.  Sometimes it seems like the simplest problems are the hardest ones to track down, and printing out a ton of messages often helps narrow down your focus.

fireside

#7
QuotePost the full console please.

I'm having a little trouble understanding what you mean.  I have a folder and in it is an html page with jars.  I double click on the html file and at the bottom of Firefox it says applet started.  I think of the console as the command line but I don't know where I would find that in a windows application.  There isn't anything on the sys tray except the mozilla app button.

QuoteIf you are loading resources using a file stream directly from a physical directory, be sure to use the "\\" directory divider if the files are local to a Microsoft OS, but "/" if the files are on a Linux OS.

But why would it work fine without the jar file, just the class and models directories and jpct, and not work with the jar file when it has exactly the same things in it?  I'm pretty sure the models directory is the problem because I can add the models folder to the folder with jars and html page and then it works, but the same models directory is already in the jar file, so for some reason it can read my class, but it can't read the models directory in the same jar file.

I used the jar view letters, cf? or something and it showed the models directory with the two files in it.  Could it be possible I need to change the directory symbol when it's a jar?  I'm using "models/file" right now.  I could try not using a directory but that would get messy later on.
click here->Fireside 7 Games<-

EgonOlsen

When your models are in the jar, you have to load them via an InputStream instead of the usual directory path. You can get that stream via this.getClass().getClassLoader().getResourceAsStream(file) for example.
When doing applets, my solution always was to put each and everything in one single jar.

fireside

O.K.  That's what I'm doing wrong then.  I just noticed that in Paul's code also.  I was just loading it getDocument base(), file.
click here->Fireside 7 Games<-

Melssj5

Hope you achieve with that. In Anyway checking the console will be usefull when working with applets.

If you are in Windows, check the system tray area (where the clock is, near os the messenger icon) the java logo. then do a right click and then clic on open console. That will show a windows where the outputs are printed. Check it.
Nada por ahora

fireside

QuoteCheck it.

O.K.  Thanks for that explanation.  It says it's not loading the model and texture so it probably is that stream problem.
click here->Fireside 7 Games<-