This code works when I run the app with "java -jar frontend2". But when I bring up my browser and click on a link to my .jnlp, it brings up the first frame with all the buttons but fails to read the jar file. I have packaged a directory of txt files in the jar for use in the app that will run on a web site.
------------------------------------------------- 210 *=* ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are created for .txt but not .class files >>> "frontend2.jar" >>> "txt" --- ReadFromAJarFile.nrx [javawsApplicationMain,javawsApplicationThreadGroup] 13 *=* if Debug_Level > 9 *=* then *=* trace results 14 *=* -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory 15 *=* do label get_next_entry 16 *=* My_JarFile_Object = JarFile(My_File_Separator || NameOfJarfile) >>> "\frontend2.jar" 26 *=* catch err=Exception 27 *=* say "Exception error ==>" err >>> "Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified)" Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified) 28 *=* end get_next_entry 29 *=* return this _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Kenneth, jnlp expects to get anything outside of the sandbox from the server due to security requirements. I can't tell but if you were expecting to open a local jar file but ....ain't gonna happen.
-----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC) Sent: Thursday, January 24, 2013 3:05 PM To: IBM Netrexx Subject: [Ibm-netrexx] problem with jar files run from a jnlp This code works when I run the app with "java -jar frontend2". But when I bring up my browser and click on a link to my .jnlp, it brings up the first frame with all the buttons but fails to read the jar file. I have packaged a directory of txt files in the jar for use in the app that will run on a web site. ------------------------------------------------- 210 *=* ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are created for .txt but not .class files >>> "frontend2.jar" >>> "txt" --- ReadFromAJarFile.nrx [javawsApplicationMain,javawsApplicationThreadGroup] 13 *=* if Debug_Level > 9 *=* then *=* trace results 14 *=* -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory 15 *=* do label get_next_entry 16 *=* My_JarFile_Object = JarFile(My_File_Separator || NameOfJarfile) >>> "\frontend2.jar" 26 *=* catch err=Exception 27 *=* say "Exception error ==>" err >>> "Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified)" Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified) 28 *=* end get_next_entry 29 *=* return this _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
The way I thought it worked was that any class and any resource (just text files in my case, no images yet) that would be involved would just need to be included in the jar file. On the workstation this works fine. I can execute "java -jar frontend2.jar" with the proper entry point and there it is. I can read any file from the archive and write to the directory I am in. Now when executed from a browser it can't read from the archive. I have copied the jar file, the .jnlp and my index.html to OMVS on the mainframe were we serve up web pages. I can get the original menu to display, but as the trace shows, it can't read from the jar file any more.
Any direction welcomed. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Measel, Mike Sent: Thursday, January 24, 2013 6:31 PM To: IBM Netrexx Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp Kenneth, jnlp expects to get anything outside of the sandbox from the server due to security requirements. I can't tell but if you were expecting to open a local jar file but ....ain't gonna happen. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC) Sent: Thursday, January 24, 2013 3:05 PM To: IBM Netrexx Subject: [Ibm-netrexx] problem with jar files run from a jnlp This code works when I run the app with "java -jar frontend2". But when I bring up my browser and click on a link to my .jnlp, it brings up the first frame with all the buttons but fails to read the jar file. I have packaged a directory of txt files in the jar for use in the app that will run on a web site. ------------------------------------------------- 210 *=* ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are created for .txt but not .class files >>> "frontend2.jar" >>> "txt" --- ReadFromAJarFile.nrx [javawsApplicationMain,javawsApplicationThreadGroup] 13 *=* if Debug_Level > 9 *=* then *=* trace results 14 *=* -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory 15 *=* do label get_next_entry 16 *=* My_JarFile_Object = JarFile(My_File_Separator || NameOfJarfile) >>> "\frontend2.jar" 26 *=* catch err=Exception 27 *=* say "Exception error ==>" err >>> "Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified)" Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified) 28 *=* end get_next_entry 29 *=* return this _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Right, there are different "rules" for things running inside the browser. Security concerns keep the java in a "sandbox". Any resource request is directed back to the webserver.
http://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/jnlpFileSyntax.html -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC) Sent: Friday, January 25, 2013 7:50 AM To: IBM Netrexx Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp The way I thought it worked was that any class and any resource (just text files in my case, no images yet) that would be involved would just need to be included in the jar file. On the workstation this works fine. I can execute "java -jar frontend2.jar" with the proper entry point and there it is. I can read any file from the archive and write to the directory I am in. Now when executed from a browser it can't read from the archive. I have copied the jar file, the .jnlp and my index.html to OMVS on the mainframe were we serve up web pages. I can get the original menu to display, but as the trace shows, it can't read from the jar file any more. Any direction welcomed. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Measel, Mike Sent: Thursday, January 24, 2013 6:31 PM To: IBM Netrexx Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp Kenneth, jnlp expects to get anything outside of the sandbox from the server due to security requirements. I can't tell but if you were expecting to open a local jar file but ....ain't gonna happen. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC) Sent: Thursday, January 24, 2013 3:05 PM To: IBM Netrexx Subject: [Ibm-netrexx] problem with jar files run from a jnlp This code works when I run the app with "java -jar frontend2". But when I bring up my browser and click on a link to my .jnlp, it brings up the first frame with all the buttons but fails to read the jar file. I have packaged a directory of txt files in the jar for use in the app that will run on a web site. ------------------------------------------------- 210 *=* ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are created for .txt but not .class files >>> "frontend2.jar" >>> "txt" --- ReadFromAJarFile.nrx [javawsApplicationMain,javawsApplicationThreadGroup] 13 *=* if Debug_Level > 9 *=* then *=* trace results 14 *=* -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory 15 *=* do label get_next_entry 16 *=* My_JarFile_Object = JarFile(My_File_Separator || NameOfJarfile) >>> "\frontend2.jar" 26 *=* catch err=Exception 27 *=* say "Exception error ==>" err >>> "Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified)" Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified) 28 *=* end get_next_entry 29 *=* return this _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
I understand the security restrictions on web loaded apps. But this is a read of data that is bundled in the jar file coming from the server. It should all be available. This is the code that works from a jar file in the directory with nothing but the jar file if executed in that directory:
-- formatted on: 13/01/10 15:42 Created from ReadFromAJarFile.nrx class ReadFromAJarFile properties inheritable static My_File_Separator = System.getProperty("file.separator") Debug_Level = int 60 method main(s=String[]) static if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are set up for .txt and .class files method ReadFromAJarFile(NameOfJarfile=String,Name_of_Type=string) -- This method receives the name of the jar file, looks at names of files in it and sends some names to be copied if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory do label get_next_entry My_JarFile_Object = JarFile(NameOfJarfile) My_Entry_List = My_JarFile_Object.entries() loop while My_Entry_List.hasMoreElements() My_JarFile_Entry=JarEntry My_Entry_List.nextElement() if Debug_Level > 5 then say "This files name = " My_JarFile_Entry.getName if Rexx(My_JarFile_Entry.getName).translate(My_File_Separator,'/').pos('.'||Name_of_Type) > 0 then do copyjarentry(My_JarFile_Object,My_JarFile_Entry,Name_of_Type||'_files') end -- another Java "gotcha": jar entries have unix file separators thus requiring the translate above end catch err=Exception say "Exception error ==>" err end get_next_entry return this -- Here is the nitty gritty code that makes it work. Probably not the best -- way to do it but I used an unbuffered byte copy for my binary files and -- buffered for the rest: -- general purpose routines -- method to copy a jarfile entry to a directory: method copyjarentry(My_JarFile_Object=JarFile,My_JarFile_Entry=JarEntry,To_Subdir=String) if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results -- receives the jarfile object, the entry name in process and the directory to put it into. Full_Path_and_Name = My_JarFile_Entry.getName File_Object=File(Full_Path_and_Name) if Debug_Level > 5 then say "Full_Path_and_Name = " Full_Path_and_Name "File_Object = " File_Object -- check if file exists already and only copy if it is not there yet if \File_Object.exists then do label File_Object_Exists rc=copyjarentrytofile(My_JarFile_Object,My_JarFile_Entry,File_Object) if rc=1 then say My_JarFile_Entry.getName "copied to:" To_Subdir end File_Object_Exists return 0 method copyjarentrytofile(My_JarFile_Object=JarFile,My_JarFile_Entry=JarEntry,File_Object=File) if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results -- receives the jarfile object, the entry name and a "File Object" do label copy_scripts -- create the input stream for the particular entry in the jar file Input_Stream = My_JarFile_Object.getInputStream(My_JarFile_Entry) if Rexx(My_JarFile_Entry.getName).pos(".txt")>0 then do Input_Reader=BufferedReader(InputStreamReader(Input_Stream)) Output_Writer=BufferedWriter(FileWriter(File_Object)) copyfile(Input_Reader,Output_Writer) Output_Writer.close end else if Rexx(My_JarFile_Entry.getName).pos(".class")>0 then do Output_Stream=FileOutputStream(File_Object) copybin(Input_Stream,Output_Stream) Output_Stream.close end catch badguy=Exception say My_JarFile_Entry.getName "copy error =" badguy return 8 end copy_scripts return 0 /* methods to copy a file: */ method copyfile(Buffed_Reader=java.io.BufferedReader,Buffed_Writer=java.io.BufferedWriter) signals IOException if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results line=Buffed_Reader.readline if line = null then return 4 Buffed_Writer.write(string line,0,line.length) trace off loop forever line=Buffed_Reader.readline if line = null then leave Buffed_Writer.newline() Buffed_Writer.write(string line,0,line.length) catch IO_Err=Exception say "copy error =" IO_Err return 8 end return 0 method copybin(Byte_Input=InputStream,Byte_Writer=OutputStream) binary signals IOException if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results A_Byte=Byte_Input.read trace off loop while A_Byte \= -1 Byte_Writer.write(A_Byte) A_Byte=Byte_Input.read catch IO_Err=Exception say "copy error =" IO_Err return 8 end return 0 -----Original Message----- Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp Right, there are different "rules" for things running inside the browser. Security concerns keep the java in a "sandbox". Any resource request is directed back to the webserver. http://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/jnlpFileSyntax.html -----Original Message----- Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp The way I thought it worked was that any class and any resource (just text files in my case, no images yet) that would be involved would just need to be included in the jar file. On the workstation this works fine. I can execute "java -jar frontend2.jar" with the proper entry point and there it is. I can read any file from the archive and write to the directory I am in. Now when executed from a browser it can't read from the archive. I have copied the jar file, the .jnlp and my index.html to OMVS on the mainframe were we serve up web pages. I can get the original menu to display, but as the trace shows, it can't read from the jar file any more. Any direction welcomed. -----Original Message----- Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp Kenneth, jnlp expects to get anything outside of the sandbox from the server due to security requirements. I can't tell but if you were expecting to open a local jar file but ....ain't gonna happen. -----Original Message----- Subject: [Ibm-netrexx] problem with jar files run from a jnlp This code works when I run the app with "java -jar frontend2". But when I bring up my browser and click on a link to my .jnlp, it brings up the first frame with all the buttons but fails to read the jar file. I have packaged a directory of txt files in the jar for use in the app that will run on a web site. ------------------------------------------------- 210 *=* ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are created for .txt but not .class files >>> "frontend2.jar" >>> "txt" --- ReadFromAJarFile.nrx [javawsApplicationMain,javawsApplicationThreadGroup] 13 *=* if Debug_Level > 9 *=* then *=* trace results 14 *=* -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory 15 *=* do label get_next_entry 16 *=* My_JarFile_Object = JarFile(My_File_Separator || NameOfJarfile) >>> "\frontend2.jar" 26 *=* catch err=Exception 27 *=* say "Exception error ==>" err >>> "Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified)" Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified) 28 *=* end get_next_entry 29 *=* return this _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Post your jnlp file so we can have a look.
-----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC) Sent: Friday, January 25, 2013 9:23 AM To: IBM Netrexx Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp I understand the security restrictions on web loaded apps. But this is a read of data that is bundled in the jar file coming from the server. It should all be available. This is the code that works from a jar file in the directory with nothing but the jar file if executed in that directory: -- formatted on: 13/01/10 15:42 Created from ReadFromAJarFile.nrx class ReadFromAJarFile properties inheritable static My_File_Separator = System.getProperty("file.separator") Debug_Level = int 60 method main(s=String[]) static if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are set up for .txt and .class files method ReadFromAJarFile(NameOfJarfile=String,Name_of_Type=string) -- This method receives the name of the jar file, looks at names of files in it and sends some names to be copied if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory do label get_next_entry My_JarFile_Object = JarFile(NameOfJarfile) My_Entry_List = My_JarFile_Object.entries() loop while My_Entry_List.hasMoreElements() My_JarFile_Entry=JarEntry My_Entry_List.nextElement() if Debug_Level > 5 then say "This files name = " My_JarFile_Entry.getName if Rexx(My_JarFile_Entry.getName).translate(My_File_Separator,'/').pos('.'||Name_of_Type) > 0 then do copyjarentry(My_JarFile_Object,My_JarFile_Entry,Name_of_Type||'_files') end -- another Java "gotcha": jar entries have unix file separators thus requiring the translate above end catch err=Exception say "Exception error ==>" err end get_next_entry return this -- Here is the nitty gritty code that makes it work. Probably not the best -- way to do it but I used an unbuffered byte copy for my binary files and -- buffered for the rest: -- general purpose routines -- method to copy a jarfile entry to a directory: method copyjarentry(My_JarFile_Object=JarFile,My_JarFile_Entry=JarEntry,To_Subdir=String) if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results -- receives the jarfile object, the entry name in process and the directory to put it into. Full_Path_and_Name = My_JarFile_Entry.getName File_Object=File(Full_Path_and_Name) if Debug_Level > 5 then say "Full_Path_and_Name = " Full_Path_and_Name "File_Object = " File_Object -- check if file exists already and only copy if it is not there yet if \File_Object.exists then do label File_Object_Exists rc=copyjarentrytofile(My_JarFile_Object,My_JarFile_Entry,File_Object) if rc=1 then say My_JarFile_Entry.getName "copied to:" To_Subdir end File_Object_Exists return 0 method copyjarentrytofile(My_JarFile_Object=JarFile,My_JarFile_Entry=JarEntry,File_Object=File) if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results -- receives the jarfile object, the entry name and a "File Object" do label copy_scripts -- create the input stream for the particular entry in the jar file Input_Stream = My_JarFile_Object.getInputStream(My_JarFile_Entry) if Rexx(My_JarFile_Entry.getName).pos(".txt")>0 then do Input_Reader=BufferedReader(InputStreamReader(Input_Stream)) Output_Writer=BufferedWriter(FileWriter(File_Object)) copyfile(Input_Reader,Output_Writer) Output_Writer.close end else if Rexx(My_JarFile_Entry.getName).pos(".class")>0 then do Output_Stream=FileOutputStream(File_Object) copybin(Input_Stream,Output_Stream) Output_Stream.close end catch badguy=Exception say My_JarFile_Entry.getName "copy error =" badguy return 8 end copy_scripts return 0 /* methods to copy a file: */ method copyfile(Buffed_Reader=java.io.BufferedReader,Buffed_Writer=java.io.BufferedWriter) signals IOException if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results line=Buffed_Reader.readline if line = null then return 4 Buffed_Writer.write(string line,0,line.length) trace off loop forever line=Buffed_Reader.readline if line = null then leave Buffed_Writer.newline() Buffed_Writer.write(string line,0,line.length) catch IO_Err=Exception say "copy error =" IO_Err return 8 end return 0 method copybin(Byte_Input=InputStream,Byte_Writer=OutputStream) binary signals IOException if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results A_Byte=Byte_Input.read trace off loop while A_Byte \= -1 Byte_Writer.write(A_Byte) A_Byte=Byte_Input.read catch IO_Err=Exception say "copy error =" IO_Err return 8 end return 0 -----Original Message----- Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp Right, there are different "rules" for things running inside the browser. Security concerns keep the java in a "sandbox". Any resource request is directed back to the webserver. http://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/jnlpFileSyntax.html -----Original Message----- Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp The way I thought it worked was that any class and any resource (just text files in my case, no images yet) that would be involved would just need to be included in the jar file. On the workstation this works fine. I can execute "java -jar frontend2.jar" with the proper entry point and there it is. I can read any file from the archive and write to the directory I am in. Now when executed from a browser it can't read from the archive. I have copied the jar file, the .jnlp and my index.html to OMVS on the mainframe were we serve up web pages. I can get the original menu to display, but as the trace shows, it can't read from the jar file any more. Any direction welcomed. -----Original Message----- Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp Kenneth, jnlp expects to get anything outside of the sandbox from the server due to security requirements. I can't tell but if you were expecting to open a local jar file but ....ain't gonna happen. -----Original Message----- Subject: [Ibm-netrexx] problem with jar files run from a jnlp This code works when I run the app with "java -jar frontend2". But when I bring up my browser and click on a link to my .jnlp, it brings up the first frame with all the buttons but fails to read the jar file. I have packaged a directory of txt files in the jar for use in the app that will run on a web site. ------------------------------------------------- 210 *=* ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are created for .txt but not .class files >>> "frontend2.jar" >>> "txt" --- ReadFromAJarFile.nrx [javawsApplicationMain,javawsApplicationThreadGroup] 13 *=* if Debug_Level > 9 *=* then *=* trace results 14 *=* -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory 15 *=* do label get_next_entry 16 *=* My_JarFile_Object = JarFile(My_File_Separator || NameOfJarfile) >>> "\frontend2.jar" 26 *=* catch err=Exception 27 *=* say "Exception error ==>" err >>> "Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified)" Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified) 28 *=* end get_next_entry 29 *=* return this _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
I think the jnlp is fine. The first image loads and displays then the file cannot be found. I think I need something like
fs = string fs = System.getProperty("file.separator"); -- rightAnswers = 0 -- wrongAnswers = 0 -- bufferIn=BufferedReader(FileReader(fs || "txt_files" || fs || afileName)) is = InputStream is = getClass().getResourceAsStream(fs || "txt_files" || fs || afileName) isr = InputStreamReader(is) reader = BufferedReader(isr) say 'Processing infile.' afileName /* The processing loop to load our table from the txt file. ***/ loop totalQCount = 0 line = "" line = reader.readLine -- get next line as Rexx string if line == null then leave totalQCount -- normal end of file parse line '"' myanswer '"' myquestion question1[totalQCount] = myquestion.strip.strip('B','\t') answer1[totalQCount] = myanswer.strip.strip('B','\t') ans_done[totalQCount] = 0 catch Z=IOException --, X=FileNotFoundException say '# error opening file' Z.getMessage finally say "loading table with: " afileName -- say '# File not found.' X.getMessage -- return inhandle end totalQCount <?xml version="1.0" encoding="utf-8"?> <jnlp spec="1.0+" codebase="http://150.45.12.18/usr/website/homepage/a00002t" href="frontend2.jnlp"> <information> <title>Jnlp Testing, use at your own risk.</title> <vendor>Ken Klein</vendor> <homepage href="usr/website/homepage/a00002t"/> <description>Testing Testing</description> </information> <security> <all-permissions/> </security> <resources> <j2se version="1.4+" /> <jar href="frontend2.jar" /> </resources> <application-desc main-class="FrontEnd2" /> </application-desc> </jnlp> -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Measel, Mike Sent: Friday, January 25, 2013 10:50 AM To: IBM Netrexx Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp Post your jnlp file so we can have a look. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Klein (TEMA TPC) Sent: Friday, January 25, 2013 9:23 AM To: IBM Netrexx Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp I understand the security restrictions on web loaded apps. But this is a read of data that is bundled in the jar file coming from the server. It should all be available. This is the code that works from a jar file in the directory with nothing but the jar file if executed in that directory: -- formatted on: 13/01/10 15:42 Created from ReadFromAJarFile.nrx class ReadFromAJarFile properties inheritable static My_File_Separator = System.getProperty("file.separator") Debug_Level = int 60 method main(s=String[]) static if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are set up for .txt and .class files method ReadFromAJarFile(NameOfJarfile=String,Name_of_Type=string) -- This method receives the name of the jar file, looks at names of files in it and sends some names to be copied if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory do label get_next_entry My_JarFile_Object = JarFile(NameOfJarfile) My_Entry_List = My_JarFile_Object.entries() loop while My_Entry_List.hasMoreElements() My_JarFile_Entry=JarEntry My_Entry_List.nextElement() if Debug_Level > 5 then say "This files name = " My_JarFile_Entry.getName if Rexx(My_JarFile_Entry.getName).translate(My_File_Separator,'/').pos('.'||Name_of_Type) > 0 then do copyjarentry(My_JarFile_Object,My_JarFile_Entry,Name_of_Type||'_files') end -- another Java "gotcha": jar entries have unix file separators thus requiring the translate above end catch err=Exception say "Exception error ==>" err end get_next_entry return this -- Here is the nitty gritty code that makes it work. Probably not the best -- way to do it but I used an unbuffered byte copy for my binary files and -- buffered for the rest: -- general purpose routines -- method to copy a jarfile entry to a directory: method copyjarentry(My_JarFile_Object=JarFile,My_JarFile_Entry=JarEntry,To_Subdir=String) if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results -- receives the jarfile object, the entry name in process and the directory to put it into. Full_Path_and_Name = My_JarFile_Entry.getName File_Object=File(Full_Path_and_Name) if Debug_Level > 5 then say "Full_Path_and_Name = " Full_Path_and_Name "File_Object = " File_Object -- check if file exists already and only copy if it is not there yet if \File_Object.exists then do label File_Object_Exists rc=copyjarentrytofile(My_JarFile_Object,My_JarFile_Entry,File_Object) if rc=1 then say My_JarFile_Entry.getName "copied to:" To_Subdir end File_Object_Exists return 0 method copyjarentrytofile(My_JarFile_Object=JarFile,My_JarFile_Entry=JarEntry,File_Object=File) if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results -- receives the jarfile object, the entry name and a "File Object" do label copy_scripts -- create the input stream for the particular entry in the jar file Input_Stream = My_JarFile_Object.getInputStream(My_JarFile_Entry) if Rexx(My_JarFile_Entry.getName).pos(".txt")>0 then do Input_Reader=BufferedReader(InputStreamReader(Input_Stream)) Output_Writer=BufferedWriter(FileWriter(File_Object)) copyfile(Input_Reader,Output_Writer) Output_Writer.close end else if Rexx(My_JarFile_Entry.getName).pos(".class")>0 then do Output_Stream=FileOutputStream(File_Object) copybin(Input_Stream,Output_Stream) Output_Stream.close end catch badguy=Exception say My_JarFile_Entry.getName "copy error =" badguy return 8 end copy_scripts return 0 /* methods to copy a file: */ method copyfile(Buffed_Reader=java.io.BufferedReader,Buffed_Writer=java.io.BufferedWriter) signals IOException if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results line=Buffed_Reader.readline if line = null then return 4 Buffed_Writer.write(string line,0,line.length) trace off loop forever line=Buffed_Reader.readline if line = null then leave Buffed_Writer.newline() Buffed_Writer.write(string line,0,line.length) catch IO_Err=Exception say "copy error =" IO_Err return 8 end return 0 method copybin(Byte_Input=InputStream,Byte_Writer=OutputStream) binary signals IOException if Debug_Level > 5 then trace all if Debug_Level > 9 then trace results A_Byte=Byte_Input.read trace off loop while A_Byte \= -1 Byte_Writer.write(A_Byte) A_Byte=Byte_Input.read catch IO_Err=Exception say "copy error =" IO_Err return 8 end return 0 -----Original Message----- Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp Right, there are different "rules" for things running inside the browser. Security concerns keep the java in a "sandbox". Any resource request is directed back to the webserver. http://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/jnlpFileSyntax.html -----Original Message----- Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp The way I thought it worked was that any class and any resource (just text files in my case, no images yet) that would be involved would just need to be included in the jar file. On the workstation this works fine. I can execute "java -jar frontend2.jar" with the proper entry point and there it is. I can read any file from the archive and write to the directory I am in. Now when executed from a browser it can't read from the archive. I have copied the jar file, the .jnlp and my index.html to OMVS on the mainframe were we serve up web pages. I can get the original menu to display, but as the trace shows, it can't read from the jar file any more. Any direction welcomed. -----Original Message----- Subject: Re: [Ibm-netrexx] problem with jar files run from a jnlp Kenneth, jnlp expects to get anything outside of the sandbox from the server due to security requirements. I can't tell but if you were expecting to open a local jar file but ....ain't gonna happen. -----Original Message----- Subject: [Ibm-netrexx] problem with jar files run from a jnlp This code works when I run the app with "java -jar frontend2". But when I bring up my browser and click on a link to my .jnlp, it brings up the first frame with all the buttons but fails to read the jar file. I have packaged a directory of txt files in the jar for use in the app that will run on a web site. ------------------------------------------------- 210 *=* ReadFromAJarFile('frontend2.jar','txt') -- sub dirs are created for .txt but not .class files >>> "frontend2.jar" >>> "txt" --- ReadFromAJarFile.nrx [javawsApplicationMain,javawsApplicationThreadGroup] 13 *=* if Debug_Level > 9 *=* then *=* trace results 14 *=* -- Here we pick out all the files in the jar that contain the type we are seeking and are not in a subdirectory 15 *=* do label get_next_entry 16 *=* My_JarFile_Object = JarFile(My_File_Separator || NameOfJarfile) >>> "\frontend2.jar" 26 *=* catch err=Exception 27 *=* say "Exception error ==>" err >>> "Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified)" Exception error ==> java.io.FileNotFoundException: \frontend2.jar (The system cannot find the file specified) 28 *=* end get_next_entry 29 *=* return this _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Retrieving Resources from JAR files http://docs.oracle.com/javase/1.5.0/docs/guide/javaws/developersguide/development.html#retrieving
Java Web Start only transfers JAR files from the Web server to the client machine. It determines where to store the JAR files on the local machine. Thus, an application cannot use disk-relative references to resources such as images and configuration files. All application resources must be retrieved from the JAR files specified in the resources section of the JNLP file, or retrieved explicitly using an HTTP request to the Web server. Storing resources in JAR files is recommended, since they will be cached on the local machine by Java Web Start. The following code example shows how to retrieve images from a JAR file: // Get current classloader ClassLoader cl = this.getClass().getClassLoader(); // Create icons Icon saveIcon = new ImageIcon(cl.getResource("images/save.gif")); Icon cutIcon = new ImageIcon(cl.getResource("images/cut.gif")); ... The example assumes that the following entries exist in one of the JAR files for the application: images/save.gif images/cut.gif _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by kenner
On Fri, Jan 25, 2013 at 7:21 PM, Kenneth Klein (TEMA TPC) <[hidden email]> wrote:
I think the jnlp is fine. The first image loads and displays then the file cannot be found. ...
<?xml version="1.0" encoding="utf-8"?> I haven't been paying any attention to the semantics of this problem at all (not my field) but the above XML looks syntactically odd. The application-desc start tag is self-closing, but is then followed by an application-desc end tag. It possibly has nothing to do with your problem, but hth.
Hugh
-- _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
I almost have it! This trace is from running the pgm from a command line prompt in the directory with the jar file: ---- snip 139 *=* LoadTable(fileIn) >>> "Yeast for substyle.txt" 598 *=* fs = System.getProperty("file.separator"); >>> "file.separator" >p> fs "\" 599 *=* cp = System.getProperty("java.class.path") >>> "java.class.path" >v> cp ".;C:\Users\keklein\REXX\NetRexx\lib\NetRexxC.jar;C:\Users\keklein\REXX\NetRexx\lib\ecj-4.2.jar;C:\Users\keklein\Java\jdk1.7.0_05\lib\tools.jar;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\Users\keklein\REXX\Netrexx\Rexx2Nrx\Rexx2Nrx.jar" 600 *=* say "Class Path=" cp >>> "Class Path= .;C:\Users\keklein\REXX\NetRexx\lib\NetRexxC.jar;C:\Users\keklein\REXX\NetRexx\lib\ecj-4.2.jar;C:\Users\keklein\Java\jdk1.7.0_05\lib\tools.jar;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\Users\keklein\REXX\Netrexx\Rexx2Nrx\Rexx2Nrx.jar" Class Path= .;C:\Users\keklein\REXX\NetRexx\lib\NetRexxC.jar;C:\Users\keklein\REXX\NetRexx\lib\ecj-4.2.jar;C:\Users\keklein\Java\jdk1.7.0_05\lib\tools.jar;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\Users\keklein\REXX\Netrexx\Rexx2Nrx\Rexx2Nrx.jar 601 *=* cl = ClassLoader 602 *=* cl = this.getclass().getClassLoader() >v> cl "sun.misc.Launcher$AppClassLoader@92e78c" 603 *=* -- name = this.getClass.getResource("txt_files" || fs || afileName); 604 *=* name = cl.getResource("txt_files" || fs || afileName); >>> "txt_files\Yeast for substyle.txt" >p> name "file:/C:/Users/KEKLEIN/REXX/NetRexx/bjcpe/txt_files%5cYeast%20for%20substyle.txt" 605 *=* is = name.openStream(); >p> is "java.io.BufferedInputStream@2f996f" 606 *=* scan = Scanner 607 *=* scan = Scanner(is); >>> "java.io.BufferedInputStream@2f996f" >v> scan "java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false][group separator=\,][decimal separator=\.][positive prefix=][negative
prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q?\E][infinity string=\Q?\E]" 608 *=* if Debug_Level > 30 >>> "0" 614 *=* isr = InputStreamReader(is) >>> "java.io.BufferedInputStream@2f996f" >v> isr "java.io.InputStreamReader@169d75d" 615 *=* reader = BufferedReader(isr) >>> "java.io.InputStreamReader@169d75d" >v> reader "java.io.BufferedReader@1ba4159" 616 *=* say 'Processing infile.' afileName >>> "Processing infile. Yeast for substyle.txt" Processing infile. Yeast for substyle.txt ---- snip This is from running the same jar file with webstart from a jarfile in my omvs website directory with IE: ---- snip 138 *=* LoadTable(fileIn) >>> "Yeast for substyle.txt" 596 *=* if Debug_Level > 15 >>> "1" *=* then *=* trace var rightAnswer wrongAnswer 597 *=* if Debug_Level > 5 >>> "1" *=* then *=* trace results 598 *=* fs = System.getProperty("file.separator"); >>> "file.separator" >p> fs "\" 599 *=* cp = System.getProperty("java.class.path") >>> "java.class.path" >v> cp "C:\\Program Files\\Java\\jre7\\lib\\deploy.jar" 600 *=* say "Class Path=" cp >>> "Class Path= C:\\Program Files\\Java\\jre7\\lib\\deploy.jar" Class Path= C:\\Program Files\\Java\\jre7\\lib\\deploy.jar 601 *=* name = URL 602 *=* name = this.getClass.getResource(fs || "txt_files" || fs || afileName); >>> "\txt_files\Yeast for substyle.txt" >v> name [null] 603 *=* is = name.openStream(); --- FrontEnd2.nrx [AWT-EventQueue-0] 249 *=* finally *=* say "Done with the Button Clicked select block of code." >>> "Done with the Button Clicked select block of code." Done with the Button Clicked select block of code. Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at fcgui.LoadTable(fcgui.nrx:603) at fcgui.<init>(fcgui.nrx:138) at FrontEnd2.KickOff(FrontEnd2.nrx:259) at FrontEnd2.actionPerformed(FrontEnd2.nrx:212) _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |