Application jar path??
Hi all:
I have the following situation:
We're writting an application where all the class files are jar'ed together.
We're supplying html help with the application.
The file structure will look like this after installation:
appDirectory
- app.jar
- helpDirectory
--- aBunchOfHelpFiles.html
The problem I have is this. I want to be able to get the path of the helpDirectory from within the application so that I can display them in some html enabled frame. getting the user's current directory is easy, getting the user's home directory is easy, but how do you get the directory where the jar is located? I've been trying to use this approach:
URL urlAppDir = ClassLoader.getSystemResource("package/App.class");
File fileAppDir = new File(urlAppDir.getFile());
while(!fileAppDir.isDirectory()){
fileAppDir = fileAppDir.getParentFile();
System.out.print("fileAppDir = " + fileAppDir);
System.out.println(" : " + fileAppDir.isDirectory());
}but it produces this output...
fileAppDir = file:\C:\A\B\C\app.jar!\package : false
fileAppDir = file:\C:\A\B\C\app.jar! : false
fileAppDir = file:\C:\A\B\C : false
fileAppDir = file:\C:\A\B : false
fileAppDir = file:\C:\A : false
fileAppDir = file:\C: : false
fileAppDir = file: : false
fileAppDir = null
<null pointer exception because fileAppDir became null and tried to execute isDirectory() method>
Why doesn't this walk up work? And is there a better approach for getting the directory in which an application's jar file exists?
Thanks in advance,
Jeremy
I found the solution to the walk up problem I was having, but I'm not exactly sure why the solution works. I needed to get the AbsoluteFile of the ParentFile. If anyone could explain this, or offer a simpler/better way of attaining an application's jar file's directory, I'd appreciate it.
URL urlAppDir = ClassLoader.getSystemResource("package/App.class");
File fileAppDir = new File(urlAppDir.getFile());
while(!fileAppDir.isDirectory()){
// Get the AbsoluteFile of the parent file...
// I'm not entirely clear what the difference is, but it works.
fileAppDir = fileAppDir.getParentFile().getAbsoluteFile();
System.out.print("fileAppDir = " + fileAppDir);
System.out.println(" : " + fileAppDir.isDirectory());
}Thanks,
Jeremy
Similar Messages
-
How to disable application jar creation in tmp folder
Hi
I am deploying an application on clustered server.
Everytime i deploy application a jar(for the application) is getting created in admin server's tmp folder in the folder WLTEMP_APP_DOWNLOADS/<application_name>/<application_name.jar>
I am deploying application in exploded format and one of its functionality is to generate csv files.
As Weblogic seems to be referring the application_name.jar I get a 404 error whenever csv files are accessed in UI.
Could somebody please suggest the settings to disable the application jar creation.The issue was with weblogic caching.
The server was creating a jar of the application in a tmp folder for every deployment .
Due to this any new file generated within deployment path was not being identified.
Disabling caching on admin server resolved the issue. -
How can I get my application Context Path?
How can I get my application Context Path via webdynpro code?
Let say I'm accesing my application with URL
https://myapp:8443/webdynpro/dispatcher/local/MyApp/App, how can I get
the value 'https://myapp:8443' from webdynpro code? In J2EE, this is
equivalent of HttpServletRequest.getContextPath() method. Do we have
this method call in webdynpro object?Hi John,
Yes you can achieve that in Web Dynpro.
Try the following -
// USE THIS FOR GETTING THE SERVER NAME AND IMPORT WEBLOGIC.JAR FILE IN THE JAVA BUILD PATH PROPERTIES
HttpServletRequest request = (( com.sap.tc.webdynpro.services.sal.adapter.core.IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();
//GETS THE HOST NAME OF THE SERVER
String strHostName = request.getServerName();
Thanks,
Sam -
When trying to deploy an ear on my local machine using the following
command:
iasdeploy deployapp -verbose foo.ear
I am getting the following error:
Severity 1: The JAR Path is : null
com.iplanet.ias.tools.buzz.iascom.DeployException: Error getting JAR
path:
at
com.iplanet.ias.tools.buzz.iascom.DeployEngine.deployToHost(Unknown
Source)
at com.iplanet.ias.tools.buzz.iascom.DeployThread.run(Unknown
Source) localhost:Error getting JAR path:
Is there somewhere in ksvradmin or somewhere else to set the JAR path?
thanks in advance,
MattHi,
Check the application server class path in
"Software/iPlanet->Application Server->6.0->Java.
Regards
Raj
[email protected] wrote:
When trying to deploy an ear on my local machine using the following
command:
iasdeploy deployapp -verbose foo.ear
I am getting the following error:
Severity 1: The JAR Path is : null
com.iplanet.ias.tools.buzz.iascom.DeployException: Error getting JAR
path:
at
com.iplanet.ias.tools.buzz.iascom.DeployEngine.deployToHost(Unknown
Source)
at com.iplanet.ias.tools.buzz.iascom.DeployThread.run(Unknown
Source) localhost:Error getting JAR path:
Is there somewhere in ksvradmin or somewhere else to set the JAR path?
thanks in advance,
Matt -
How to view images from application's path?
Hello,
I am using the codes below to view images from an ACCESS database listed as ".\image.png", the images are included in the application's path. I'm able to view the images while running crystal reports alone; However when I include the same report and databse in my VB.NET application, the images don't show. I was told that the report looks for the images in a temp folder, an alternative solution would be to copy the image files to a temp folder before attempting to run the report, but so many things can go wrong with such approach. Do you have a better solution to this problem?
Thanks in advance.
Victor
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myaop6viewer As New aop6viewer
Dim myaop6report As New AOP6V2
Dim crConnectionInfo As ConnectionInfo = New ConnectionInfo
crConnectionInfo.ServerName = (Application.StartupPath & "\AOP6V2.mdb")
crConnectionInfo.Password = "testaop"
setDBLogonForReport(crConnectionInfo, myaop6report)
myaop6report.RecordSelectionFormula = "isnull({image.country}) = false"
With myaop6viewer
.CrystalViewer22.ReportSource = myaop6report
.Show()
End With
myaop6report = Nothing
End Sub
Private Sub setDBLogonForReport(ByVal connection As ConnectionInfo, ByVal report As ReportDocument)
Dim mytables As Tables = report.Database.Tables
Dim mytable As CrystalDecisions.CrystalReports.Engine.Table
For Each mytable In mytables
Dim mytablelogoninfo As TableLogOnInfo = mytable.LogOnInfo
mytablelogoninfo.ConnectionInfo = connection
mytable.ApplyLogOnInfo(mytablelogoninfo)
Next
End SubI tried following your suggestions, but I'm unable to link to the image file from the application, can you please help me link to the image from the application.
1. Created a formula name test with the folowing data:
".\test.png"
2. In the Gphics Location, entered:
{@test}
3. Below is the code in my application
Imports System.Data.OleDb
Imports Microsoft.VisualBasic.ControlChars
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myaop6viewer As New aop6viewer
Dim myaop6report As New AOP6V2
Dim crConnectionInfo As ConnectionInfo = New ConnectionInfo
crConnectionInfo.ServerName = (Application.StartupPath & "\AOP6V2.mdb")
crConnectionInfo.Password = "testaop"
setDBLogonForReport(crConnectionInfo, myaop6report)
myaop6report.DataDefinition.FormulaFields.Item("@test").Text = "path + picture name" '???????
myaop6report.RecordSelectionFormula = "isnull({image.country}) = false"
With myaop6viewer
.CrystalViewer22.ReportSource = myaop6report
.Show()
End With
myaop6report = Nothing
End Sub
Private Sub setDBLogonForReport(ByVal connection As ConnectionInfo, ByVal report As ReportDocument)
Dim mytables As Tables = report.Database.Tables
Dim mytable As CrystalDecisions.CrystalReports.Engine.Table
For Each mytable In mytables
Dim mytablelogoninfo As TableLogOnInfo = mytable.LogOnInfo
mytablelogoninfo.ConnectionInfo = connection
mytable.ApplyLogOnInfo(mytablelogoninfo)
Next
End Sub
Thanks,
Victor -
Deploying EJBs with same name in different application jars on JBOSS
Hi,
We are attempting to deploy entity beans with the same name in 2 different EJB application jars on jboss 3.2.5. One bean is an extension of the other, so some of the DB columns they refer to are the same (they access different DB tables in different tablespaces). However, the field names corresponding to these DB columns in the beans themselves are different (i.e. DB column serviceid is associated with the field serviceid in one bean and service_id in the other).
We have altered jboss.xml for one of the EJB applications so that the jndi-name used to access that application's bean is different to the jndi-name used to access the entity bean in the other EJB jar.
However, when we attempt to deploy both jar files on the same jboss server, one of the applications deploys successfully and when we deploy the other, we get EJB spec violation errors, such as the following:
14:18:34,631 WARN [verifier] EJB spec violation:
Bean : CommunityAddress
Section: 10.6.2
Warning: The entity bean class must define a get accessor for each CMP field.
Info : Field: service_id
I'm presuming that this is because the bean which references the serviceid DB column with a field called serviceid is being mixed up with the other bean, which has a service_id field.
Can anyone tell me if there is anything else that is required to get entity beans/EJBs in different applications but with the same names (and some overlapping fields, etc) deployed successfully on the same jboss server apart from editing jboss.xml for one of the applications?
Is this a jbosscmp-jdbc.xml issue?
Any help much appreciated,
MauriceHi Srinath
Thanks for your response. Its not cloning, its like check-in file first, then check-out the file and do some editing and then again upload the same file with different revision number using RIDC. I got the solution now.
Regards
Raj -
Java -jar application.jar not finding file?
I have an application program that contains the
following two lines of code:
FileInputStream sf = new FileInputStream "CustomWorld.ini");
settings.load(sf);
and when I run it as:
java application
it runs fine but if I run it as:
java -jar -classpath .;application.jar application.jar
it can't find the "CustomWorld.ini" file. Why is that
and how can I fix it?
Many thanks for your help.
PS: to create the jar file I used:
jar -cvfm application.jar application.mf application.class CustomWorld.iniOnce your CustomWorld.ini file is in the jar, you can no longer access it directly with a FileReader. JDK 1.1 included resource locators to java.lang.Class...
URL url = application.class.getResource("/CustomWorld.ini");
if (url != null) { // resource was found
InputStream in = url.openStream();
settings.load(in);
} else {
// fail gracefully or use defaults
}Note that the CustomWorld.ini file will need to be in the classpath or the root folder of the jar file for this to work.
Regards,
-Troy -
Accessing web application JAR files from applet
I've got an applet which is part of a web application.
All the web application JARs are in the webapps/myappl/WEB-INF/lib directory, and I
can't seem to place anything in that directory on the archive attribute of <OBJECT> tag.
I'm running into trouble because I'm sending objects from the servlet to the applet and keep getting classnot found during deserialization because I've missed some jar file on the archive attribute. I've had to copy lots of jar files up to where the codebase in the HTML file is to make this run. My question is this.
Is it better to just change the tomcat security policy file (catalina.policy in tomcat conf directory) so that the JARs are directly accessible and I don't have to copy them from WEB-INF/lib???? Has anyone done this before? What would the line look like?
I'm assuming that I have to follow the instructions (THAT I DON'T UNDERSTAND)
at the bottom of the policy file. Can someone help me out here????
should I have something like
grant codeBase "file:${catalina.home}/webapps/myappl/WEB-INF/classes/-"
{ permission java.security.AllPermission; };
grant codeBase "file:${catalina.home}/webapps/myappl/WEB-INF/lib/-"
{ permission java.security.AllPermission; };
Will this allow me to place references to jar files (and the classes directory) in the archive attribute, such as
<OBJECT ..... >
<param name="archive" value="../WEB-INF/lib/applet.jar,../WEB-INF/lib/someapp.jar,../WEB-INF/classes" />trailer for catalina.policy is
// You can assign additional permissions to particular web applications by
// adding additional "grant" entries here, based on the code base for that
// application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files.
// Different permissions can be granted to JSP pages, classes loaded from
// the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/
// directory, or even to individual jar files in the /WEB-INF/lib/ directory.
// For instance, assume that the standard "examples" application
// included a JDBC driver that needed to establish a network connection to the
// corresponding database and used the scrape taglib to get the weather from
// the NOAA web server. You might create a "grant" entries like this:
// The permissions granted to the context root directory apply to JSP pages.
// grant codeBase "file:${catalina.home}/webapps/examples/-" {
// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect";
// permission java.net.SocketPermission "*.noaa.gov:80", "connect";
// The permissions granted to the context WEB-INF/classes directory
// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/classes/-" {
// The permission granted to your JDBC driver
// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/lib/driver.jar" {
// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect";
// The permission granted to the scrape taglib
// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/lib/scrape.jar" {
// permission java.net.SocketPermission "*.noaa.gov:80", "connect";
// };Thank you for your reply.
As I mentioned in my first post I had seen a couple of posts mentioning ServletContext before, but dismissed them as I am not using any servlets of my own. However, since you showed me exactly how it was used I realised I could probably just use a dummy servlet to get this information.
The following page suggests a couple of techniques for doing just this.
http://www.jguru.com/forums/view.jsp?EID=1087411
So I think that's me sorted, cheers. -
Regarding finding of word in a string of Application Server Path
Hi All,
I have issue related to finding a certain <b>file name(S)</b> from given <b>Application Server Path</b>.
Here is the actual issue:
In my Selection-Screen i have one field by the name of <b>Application Server Path</b> - /pw/data/erp/D5S/pp/down/eppi0720.txt
Like wise he might enter diffrent file name(s) (or) diffrent pat(s) as per requirement.
Here my requirement is i need to find file discarding path in to one variable - Remember path might also differ also file name might also differ.
Is there any <b>Keyword/Command</b> by which we can findout only <b>filename</b> from the <b>path</b>!
I think with <b>'/'</b> operator we can solve this issue.
If any body knows solution please post.
Thanks in advance.
Thanks & Regards,
Rayeez.Hi,
use fm EPS_GET_DIRECTORY_LISTING'
example:
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
DESTINATION q
EXPORTING
dir_name = folder
file_mask = mask
IMPORTING
file_counter = cnt_file
error_counter = err_file
TABLES
dir_list = dir_list
Andreas -
Application jar file is corrupt
Hi Everyone,
Having written a very simple application using ME software develeopement kit, when ran the emulator prompts me to either INSTALL APPLICATION or MANAGE CERTIFICATE AURTHORITIES.
If INSTALL APPLICATION is selected I'm then prompted to ENTER A WEBSITE TO INSTALL FROM into a textbox. MANAGE CERTIFICATE AURTHORITIES presents some spurious code and I don't know what it means. However when ran for the first time, everything seemed to go swimmingly untill I was informe of (I Think) 'Application jar file is corrupt' and then subsequently as described above.
I don't know a great deel about computers, but looks to me like a random problem requiring a random solution - very frustrating! If anyone would like to help I'd be very greatful indeed.
Jamespavanpotru, welcome to the forum. Please don't post in threads that are long dead. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
I'm locking this thread now.
db -
Including extensions in my application JAR
Hi. I have an application in a JAR-file the uses some extension classes also found in a JAR-file. To run my application I have to put the extension JAR-file in ...\JavaSoft\JRE\1.3.1\lib\ext\.
I would like to be able to distribute my application in a single JAR-file. Can this be done by for example including the extension JAR in my application JAR? (And how?)
Help appreciated, thanks!i have a similar problems to this one
1)
problem is ... i jus downloaded JRE 1.4.2 .. i also have JRE 1.4.1_03 .. when i select JRE 1.4.2 .. it doesnt download the required requird JAR file no popup is shown the applet loads succesfully but obviously doest run becoz the requird JAR file was not installed. but when i use the older JRE 1.4.1_03 it shows the popup for download and installs the JAR file in the lib/ext .. can n e one help me on this?
2) another prblem is after downloading the JAR in JRE 1.4.1_03 ..
i have an applet that uses another JAR file that is of about 1.5 MB ... i want it to get this JAR installed on the client when the client first time access the WebPage
the problem is that it downloads the first time and get installed and runs fine but when i refresh the page or visit the site again .. it downloads again so its useless i jus want it to download once
i guess theres sum setting in the mansifest file or sumthin ??
n e help in this regard wud be much appriciated
faraz! -
How-to get the JSF application context path?
I want to do a redirect from within a JSF backing bean. How do I get the application context path?
I plan to do this in the constructor of the backing beans in order to validate the user has previously logged in.
public BackingBeanName()
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = HttpSession)facesContext.getExternalContext().getSession(false);
HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
userid = (String)session.getAttribute("userid");
if (userid == null) {
logger.info("userid attribute is not in session");
ExternalContext ec = facesContext.getExternalContext();
appContextPath = ???????????????????????;
String redirectTo = appContextPath + "/logon.jsp";
try {
ec.redirect(redirectTo);
catch (IOException e) {
String msg = "redirect to " + redirectTo + " failed";
logger.severe(msg);
return; // throw an exception instead of return;
Regards,
Al MalinFrank, your suggestion of using JSF global navigation to the logon page looks like what I need but I need some advice implementing it.
My backing bean constructor looks like this:
public Search()
FacesContext facesContext = FacesContext.getCurrentInstance();
String userid = GpaUtil.getSessionUserid(facesContext);
if (userid == null)
logger.info("session userid not found, going to logon page");
??????? What goes here ????????
??????? I think I need to fire an event but I'm not sure how to do it, ????????
??????? let alone if this is what needs to be done ????????
??????? or even if this is the right spot in the code ????????
gpas = ProductApproval.retrieveList("1=1","1");
FWIW, the navigation rule looks like this:
<navigation-rule>
<navigation-case>
<from-outcome>goLogon</from-outcome>
<to-view-id>/logon.jsp</to-view-id>
</navigation-case>
</navigation-rule>
Your help is greatly appreciated.
Regards,
Al Malin -
Re-download application jars from server issue
hello,
i have a "little" problem: by every start of an application the WebStart loads all the application jars from the server again. (only Vista version affected) Can anybody help please?
Thank you,
Eugen CojocaruI guess you're not using explicit versioning (that should solve it).
Are you using the JnlpDownloadServlet or one of your own?
Are you sure it's a Vista problem?
Did you check PC time and server time?
Did you check you're receiving 'If-Modified-Since' header server-side? -
The application "Jar Launcher" can't be opened
When I am open a Jar file, it aways say: The application "Jar Launcher" can't be opened, then it says: "-1712" I am using the most update Java. I am also using Marvelicks OSX 10.9.5. My computer doesn't have a lot of issues. May someone help me?
Restart the computer and try again.
-
Retrieving Jar path in the HD from within the jar?
I have a small problem. I wrote a program which is packed in a jar file and this program is able to compile and run java files (Which I do by running javac and java processes) but the kind of files that this program compiles requires some other libraries inside the same package (In the jar file) so I am wondering how can I retrieve the jar path in the harddisk from within this jar because at the moment I ask the user where the program is and I think it is kind of ugly to ask the user where the program is from within the exact same program we are looking for.
Hope I made myself understandable.
Best Regards
NooKThanks for the answer. I mistakenlly ended writing a new thread (New to the forum)
but if you would kindly look here, I have other problem now which I have been working on for a whole day.
http://forum.java.sun.com/thread.jsp?thread=524717&forum=31&message=2514471
Best Regards
NooK
Maybe you are looking for
-
Jabber for iPhone and iPad cannot receive calls
We currently have Call Manager 9.1.1 and Presence 9.1.1. I am starting to use the Jabber Client for iPhone and iPad, but am having trouble receiving calls dialed to a particular extension. If I can go settings for the iPhone Jabber client as an examp
-
UI (User Interface) text size and colors
Recent versions of Elements (7, 8, 9) have changed to a user interface which is predominantly shades of gray and black with few if any user options for color or font. The font size cannot be altered because Adobe use their own pixel-based font which
-
Ever since Youtube "change casting" (about 6 weeks ago), i can't see anymore a Youtube video even amid other sites or bloggs, with browzer mozilla firefox only (the others do it!!) because all the time sent me an error message when trying to play it.
-
how much does a person have to custom when importing out iphone 3gs/iphone 4/ipad 2 from USA
-
Won't display playlists in numerical order
Hello, My iPod won't display my playlists in numerical order. Playlist 1 is listed below number 2 and 3. I've tried dragging it with no success. Thanks.