Author Topic: Getting jar to work on Vista  (Read 6454 times)

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Getting jar to work on Vista
« on: July 28, 2008, 04:44:07 pm »
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<-

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: Getting jar to work on Vista
« Reply #1 on: July 28, 2008, 05:42:02 pm »
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<-

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: Getting jar to work on Vista
« Reply #2 on: July 28, 2008, 06:31:47 pm »
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.
« Last Edit: July 28, 2008, 06:34:43 pm by fireside »
click here->Fireside 7 Games<-

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Getting jar to work on Vista
« Reply #3 on: July 28, 2008, 07:48:05 pm »
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

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: Getting jar to work on Vista
« Reply #4 on: July 28, 2008, 09:11:51 pm »
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.
« Last Edit: July 28, 2008, 09:18:32 pm by fireside »
click here->Fireside 7 Games<-

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Getting jar to work on Vista
« Reply #5 on: July 28, 2008, 09:47:52 pm »
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

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Getting jar to work on Vista
« Reply #6 on: July 28, 2008, 10:46:24 pm »
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:

Code: [Select]
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.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: Getting jar to work on Vista
« Reply #7 on: July 28, 2008, 11:05:49 pm »
Quote
Post 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.

Quote
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.

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.
« Last Edit: July 28, 2008, 11:24:47 pm by fireside »
click here->Fireside 7 Games<-

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Getting jar to work on Vista
« Reply #8 on: July 28, 2008, 11:31:03 pm »
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
Code: [Select]
this.getClass().getClassLoader().getResourceAsStream(file) for example.
When doing applets, my solution always was to put each and everything in one single jar.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: Getting jar to work on Vista
« Reply #9 on: July 28, 2008, 11:33:40 pm »
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<-

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Getting jar to work on Vista
« Reply #10 on: July 28, 2008, 11:44:53 pm »
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

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: Getting jar to work on Vista
« Reply #11 on: July 29, 2008, 12:40:59 am »
Quote
Check 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<-