Storing data with executable JAR
if I have an executable JAR that needs to read and write from a text file so that users can customize the program, can I put the text file or any kind of database inside the JAR or does it have to go outside. Also, what is the best way to store such data, in a database or in a text file?
if I have an executable JAR that needs to read and
write from a text file so that users can customize
the program, can I put the text file or any kind of
database inside the JAR or does it have to go
outside. I think it's safe to say that you'd need to create a folder to keep your files in. i.e. the Jar won't get updated.
Also, what is the best way to store such
data, in a database or in a text file?Depends, a small amount of simple data should go in a flat file, .txt is fine, whatever. If you have lots of (possibly complex) data and relationships between the data, etc. then you'd likely use a database.
Similar Messages
-
hi there
if i associate my apple id with another email will i lose my icloud data or i will still be able to access all my stored data with the new linked to my apple id email address?
i mean i am not signing up for a new account, just changing my old id primary email which is my apple id login into account.
in other words, www.icloud.com will recognize that it is still me if i login on the site? will i be able to see there all my stored information?
and if i change my password, does it automatically changes the @icloud.com password which should be the same as my apple id pass?
thanksAfter opening the email it shoud of had you enter the Apple ID and password. Using certian web browser's can cause errors. You can adjust securty settings (big pain) or you use another browser. Using Firefox or Safari should do the trick.
Let me know if using Firefox or Safari resolved it. -
Could not find the main class error with executable jar
Hello,
I have troubles creating an executable jar file and I ran out of ideas how to solve it so I would appreciate some help.
I have created a jar file with the export function in eclipse
the Manifest.MF file contains:
Manifest-Version: 1.0
Main-Class: view.AppTennisViewI tried starting the file with a batch file which contains following code:
@echo off
javaw -classpath c:\TennisHSQLDB_GC2\tennisApp.jar
@start javaw -jar tennisApp.jar
exitthe batch file and the jar are both located in c:\TennisHSQLDB_GC2.
When i try command line I get the same result.
I also tried alternate statements such as SET CLASSPATH iso javaw -classpath and including the classpath in the manifest file but no luck. It keeps given me the error: could not find the main class. program will exit
Anyone any suggestions for my problem?nevermind, found it.
classpath in manifest was incorrect -
Problem with executable jar file
Hi,
I wrote a simple little xml based app in eclipse, it had xalan and xerces in build path. I created an executuable jar that ran fine on my machine; I was able to move it to different directories and launch it successfully, but when I put the jar file on a network directory and asked a coworker to try running it, they got a message that said it couldn't find the main class.
how do you deal with that?
thanks,
bpthey got a message that said it couldn't find the main class.
Are you sure?
If you are sure then none of the other responses will help.
That error suggests one of the following
1. The jar you moved is not the jar that you are running.
2. Your co-workers did not execute it correctly.
3. You do not have an executable jar (and you are not testing it correctly on your box.)
How exectly did they run it?
The standard double click will give an error about "Main-Class" with that specific text when you attempt to run a jar that is not in fact an executable jar.
That error is NOT the same as the standard class not found error. -
Newbie's problem with executable jar file
hello
i create an executable jar file and it seems ok except it fails to locate all of my image files.
when i use
java -jar myproject.jar
it fails to display included pictures and files.
however, when i extract this jar file and run, it works fine (displays everything).
do i need to do add some informations about these included file's information into Manifest file?
thank youthank you for the reply.
i have searched through java, and find "class javax.commerce.cassette.JARCassetteLoader". is this one you referred? i have used file related examples from the java-swing samples.
//post - return the file path
protected static ImageIcon getImageIcon(String path)
java.net.URL imgURL = TestDialog.class.getResource(path);
if (imgURL != null)
return new ImageIcon(imgURL, description);
else
System.out.println("Couldn't find file: " + path);
return null;
then i just use
ImageIcon icon = getImageIcon("images"+File.separator+"simple.gif"); // images\simple.gif
thank you -
Storing data with no real key.
Hello,
I'm trying to optimize our storage backend once more. We currently am able to switch between a simple RandomAccessFile and a BerkeleyDB backend. However I think we don't need a B-tree or something. I'm working on a treebased storage system and due to our simple node to nodePage mapping we know in advance without any index structures where the nodes reside (in which in memory NodePage). For our file backend we simply use offset values and "equip" references with this offset to the NodePages on external storage. Instead of the offset we simply used an integer-counter which is incremented after storing a databaseEntry as keys for referencing the on-disc storage. However I think a B-tree will be too much in this case and maybe another solution is way better. We store several revisions of the data using full dumps, incremental or differential dumps, however everytime storing an additional B-tree for referencing the on-disc data multiplies the cost (as it is most probably not a persistent B-tree (terminology as in persistent functional datastructures)). The latter would be very very cool, however :-) In the file backend we simply add new data at the end and as of now never delete any data before (for instance as in ZFS/Btree copy on write). In the BerkeleyDB backend we simply increment the counter everytime to store new data and reference it.
kind regards,
JohannesOk, if you need transactions, that's a good reason to use a database. The converse question is: What's wrong with your current use of BDB, what problem are you trying to solve with it? I think the answer is that you're trying to improve performance, and you think if BDB could provide an access method where the direct file offset is passed into the access methods, it would be faster. That's not practical, because the physical address of records on disk changes over time, for example, when the log cleaner migrates records forward.
To improve performance with BDB, a better approach is to read the FAQ performance section and (as recommended there) start by running DbCacheSize to see if your cache is large enough to hold all BINs. And if you're not on JE 5 yet, upgrade to JE 5 to get its performance improvements.
--mark -
Hi,
I have a jar that looks like this:
MyJar.jar
meta-inf
manifest.mf
package-name
classesThe manifest looks like this:
Main-Class:package-name.MainClass
When I execute my jar file, I get an error, that looks like this:
Failed to load Main-Class manifest attribute from [jar-file].
How come? I've created the jar using winzip with no compression, and this has worked for me before. What am I doing wrong?
Thanks in advance,
NilleYou appear to be missing the blank space between the colon and the class name, which appears in all the examples in the tutorial. And you need a LF or a CR/LF at the end of that, but I can't tell if you have that or not.
-
How do I merge data from table1 on server 1 to final table on server 2 with a stored procedure to execute every so
many hours.How big is the table on server B? Is that possible to bring the all data into a server A and merge the data locally?
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How do I merge data from table1 on server 1 to final table on server 2 with a stored procedure to execute every so many hours.
Hello,
If you had configure server2 as
linked server on the server1, you can run the following statement inside stored proceduce to copy table data. And then create a job to the run stored proceduce every 4 hours.
Insert Into Server2.Database2.dbo.Table2
(Cols)
Select Cols From Server1.Database1.dbo.Table1
Or you can use the SQL Server Import and Export Wizard to export the data from server1 to server2, save the SSIS package created by the wizard on the SQL Server, create a job to run the SSIS package.
Reference:http://technet.microsoft.com/en-us/library/ms141209.aspx
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support -
BPC5.1 - Data manager package to Stored proc with custom return codes
Hi all,
Does anyone have experience passing the return codes from a stored procedure back into the eData "view status" package progress or event log details?
When my stored procedure throws errors, the offending SQL code shows up in the pacakge details, which is helpful. But what I'd really like is to structure my stored proc with return codes
0 = everything's wonderful
1 = invalid category / time combination
2 = unauthorized
3 = no data to process
And then handle these codes as either "completed" "warning" or "error" in the package progress.
And ideally, I'd like to put some meaningful message about the warnings & errors, directly into the log details, so the user can fix the problem themselves rather than ask the IT guy to trouble-shoot.
Any tips? I've started playing with using the on-complete, on-success, on-failure routing of different tasks within the DTSX package (SQL 2005), but I'm just working on a trial-and-error basis right now. (With # of errors = # of trials.)
Thanks,
TimIn case anyone's interested, I've solved this by tracking my return codes as a package variable.
Within the package, I have conditional logic moving from task to task, evaluating the return code to check for various conditions, and selecting which tasks to perform accordingly.
In the last task, I run a final stored procedure which posts some data (completion time & status) to a custom transaction log table, and then if the return code is not zero, I script and execute some SQL which I know will throw a "fake" error. The SQL statement itself includes the key information I want the end user to see. For example
Select InvalidEntitySelection [USEast1],TransactionID [12340] from ThisTableDoesntExist
Select UnauthorizedUser [Tim], TransactionID [12345] from ThisTableDoesntExist
Select WorkStatusIsLocked [USEast1 Actual 2008], TransactionID [12345] from ThisTableDoesntExist
It's not exactly elegant, but it gets the message across, which is all that I need. In this way, the end user sees that the package failed with an error, and when they look at the package details, they can see the problem. They can pass on the transaction ID to an administrator to look into the details, if they can't figure it out on their own.
Sorin, I never managed to figure out how to use a VB task to send the information back to the user, plus force the package to end in an error. I'm sure there's a way to do so, but this seems to work for my requirement.
I'm not entirely happy with the "fake error" approach, but I don't know if BPC has any support for "intentional" programming of errors in the DTS scripting toolset.
Thanks,
Tim -
How to get a file in the same dir with the jar-executable
Hi,
I need to read/write a file that exists in the same directory with the jar-executable. How can i do that? I think that when i specify no path for the file, the file has to be in current path. (Is that right?)
Note: I do not know in which directory the jar and the file are.
Thanx in advanceHi,
I need to read/write a file that exists in the same
directory with the jar-executable. How can i do that?
I think that when i specify no path for the file, the
file has to be in current path. (Is that right?)
Note: I do not know in which directory the jar and
the file are.
Thanx in advance
When you specify no path for the file, the file has to be in the directory where the virtual machine was started. ( the directory the java command was invoked in .)
If you can't control the directory in which the vm is started, but you know the name of the .jar file you can do the following. This trick takes advantage of the fact that if you are using classes in a jar file, the name of the jar file must be in your classpath.
public static String getPathOfJar( String nameOfJar )
throws Exception
StringTokenizer st = new StringTokenizer(
System.getProperty( "java.class.path" ) ,
System.getProperty( "path.separator" ) );
String jarfile = "";
while ( st.hasMoreTokens() )
String token = st.nextToken();
if ( token.indexOf( nameOfJar ) > -1 )
jarfile = token;
break;
if ( jarfile.equals("") ) throw new Exception( "Jar not found in classpath" );
String path = jarfile.substring( 0 , jarfile.indexOf( nameOfJar ) );
return path;
//To open a file in the same directory as the sun archive tools.jar
File f = new File( getPathofJar( "tools.jar" ) + "someFile.txt" ); -
Executing a Stored Procedure with OUT Variables
When you execute a stored proc withi OUT variables, do you have to add in the "Declare" section and "Begin/End" sections? Or can you just use "EXECUTE <stored proc>"??
When you execute a stored proc withi OUT variables, do you have to add in the "Declare" section and "Begin/End" sections?
Or can you just use "EXECUTE <stored proc>"?? You mean this?:
michaels> create or replace procedure p (o out varchar2)
as
begin
o := 'Some out variable';
end p;
Procedure created.
michaels> var o varchar2(50)
michaels> exec p(:o)
PL/SQL procedure successfully completed.
michaels> print o
o
Some out variable -
Problem with execute SSIS package from stored procedure
Hi,
I would like to execute SSIS package from stored procedure. Therefore, I implemented sp which exec SSISDB.CATALOG.CREATE_EXECUTION method. When I try to test it from SSMS on remote server, I got error that
I was able to solve by adding “WITH EXECUTE AS …”. Then I got another error: The server principal "Domain\user" is not able to access the database "SSISDB" under the current security context. On Internet, I found a couple post that describe
how to access SSIS catalog (one of them by Ke Yang -
http://blogs.msdn.com/b/mattm/archive/2012/03/20/ssis-catalog-access-control-tips.aspx). It didn’t help. I’m still getting the error message.
How to debug this issue?
Any suggestion?
Thanks
SQL Server 2014 BISSMS does not propagate user credentials thus the error
Arthur
MyBlog
Twitter -
How to execute a stored procedure with an out parameter ?
Guys I am struggling with executing a stored procedure from sql plus.I mean my stored procedure has 2 input parameter and 1 out put parameter (status of the execution).
MY_PROCEDURE(p_name in varchar2,p_age in number,p_status out varchar2)
end my_procedure;
When I say
EXECUTE MY_PROCEDURE('manohar','Shetty');
i get insufficient parameters errors.
please help.EXECUTE isn't a valid PL/SQL construct. It's a SQL*Plus command. You don't want to put any SQL*Plus commands in a PL/SQL block.
You can always execute a stored procedure purely through PL/SQL
begin
my_stored_procedure( x, y, z );
end;SQL*Plus happens to give you the execute command so you can avoid the begin and end statements.
Justin -
How to execute plsql stored procedure with DbAccess
sessionInfo object can give DbAccess .through
which u can use javax.infobus.DbAccess API to
execute sql satement and stored procedures according to infobus API .iam able to
execute simple query by using executeCommand() ,executeRetrival() ?. how to execute stored procedures with executeRetrieval() .
how to take in and out parameters
suggestions are welcome
waiting for your suggestionsI am also looking for the same.
Did you get any info on this
Thanks,
jagan
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by chandra sekhar ([email protected]):
sessionInfo object can give DbAccess .through
which u can use javax.infobus.DbAccess API to
execute sql satement and stored procedures according to infobus API .iam able to
execute simple query by using executeCommand() ,executeRetrival() ?. how to execute stored procedures with executeRetrieval() .
how to take in and out parameters
suggestions are welcome
waiting for your suggestions<HR></BLOCKQUOTE>
null
Maybe you are looking for
-
Buzz/alert in calendar doesn't work
Hi, in my MBP 15" retina late 2013 with 10.10 doesn't work the buzz when appears the notice in my notification center. In notification center of system preferences the sound is on but it doesn't work. OSX 10.10 Yosemite. Regards
-
After calling XDO data engine, error is coming but report is completing.
There is a strange situation i am facing with one XML report.XML data definition of this report has two trigger. One before report trigger and other after report trigger. While running(using concurrent program) the report is completed with following
-
Letter Of Credit ( LC )?
is oracle payable and purchasing support LC? Is not What The Suggetion Work Around Must Go To Implemented? Thanks
-
Hi all, With an intention to sun some sample programmes for JAXM, I have downloaded "JavaTM Web Services Developer Pack 2.0" from Sun's website, but unfortunately I couldn't find the package javax.xml.messaging. Can someone help findout where's this
-
I cannot see PDF files on my Ipad3 when in webvista. I can see the first page and part of the second page, but cannot scroll down. Any ideas