JAR file Database connection - database

a Database acces and Search Program.
a JAR file make use Windows command
a JAR file make use Eclipse Export->Jar file
run as 1 ... that run
run as 2 ... that error -> database connection NULL
1 source file and 2 source file same directory position, same files
please tell me , How I do about case 2 ??
.. I used library classes12.jar

download mysql-connector-java-5.1.16-bin.jar
If you have then set as an external jar file in the libraries section of Eclipse->Project->Properties->Java Build Path. Then make jar.Hope it helps.

Related

Can't open text file in war folder, AccessControlException thrown?

I have a foo.txt file in my /war folder. I'm trying to open it using the File class, but get an exception:
java.security.AccessControlException: access denied (java.io.FilePermission
/foo.txt read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:549)
...
From reading the docs on static/resource files, it seems like the text file should already be available. Does it need some extra setting to allow reading?:
https://developers.google.com/appengine/docs/java/config/appconfig?hl=en#Static_Files_and_Resource_Files
I'm using the local dev server on a mac.
Thanks
I suggest that if you are going to read data files in your Java code and need a place to put your data files (.txt or .csv), etc -- then do the following:
Go to WEB-INF folder
Create some folder inside of the WEB-INF folder. e.g. WEB-INF\data
Place your files in the above folder. E.g. sample.txt
In your Java IO code, you can then refer to the file via WEB-INF\data\sample.txt

GAE plugin or GAE appcfg.cmd are not working with --enable_jar_splitting parameter

I have this error message:
Preparing to deploy: Created staging directory at:
'C:\Users\leet\AppData\Local\Temp\appcfg4768292050846213939.tmp'
Scanning for jsp files. Compiling jsp files. Scanning files on
local disk. java.io.IOException: Jar
C:\Users\leet\AppData\Local\Temp\appcfg4768292050846213939.tmp\WEB-INF\lib\appengine-api-1.0-sdk-1.7.7.jar
is too large. Consider using --enable_jar_splitting.
I issued the command like this, but it does not work with --enable_jar_splitting.
"C:\Program Files\Java\jdk1.7.0_17\bin\java.exe" -Xmx1100m -cp
"%~dp0..\lib\appengine-tools-api.jar"
com.google.appengine.tools.admin.AppCfg --enable_jar_splitting -e
user#domain.com update "C:\myfolder\myproject\war"
Any comment?
The Java App Engine 1.7.7.1 SDK has been released to address this windows specific issue.
The Google Eclipse plugin has been updated, as well as the Google App Engine Maven artifacts and plugin (just use the 1.7.7.1 version).
to solve the library error message, you have to do this:
1) open your windows explorer and locate it to your eclipse folder. e.g. ".\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.7.7\appengine-java-sdk-1.7.7\lib\user".
2) you will then see a file called "appengine-api-1.0-sdk-1.7.7.jar", rename it to "appengine-api-1.0-sdk-1.7.7.original". (just don't delete as you need in future)
3) copy that 2 files you created earlier - "appengine-api-1.0-sdk-1.7.7-1.jar" and "appengine-api-1.0-sdk-1.7.7-2.jar" and paste into this folder.
4) switch it eclipse ide, clean the project and rebuild it. then, the error message will go away.
i solved the issue by splitting the "appengine-api-1.0-sdk-1.7.7.jar" file my own.
in case anyone else want to know how to do that, follow these steps
1) unzip "appengine-api-1.0-sdk-1.7.7.jar" file from 7z.
2) balance them into 2 folders (each about 15mb) regardless any structure.
3) name the first folder as "appengine-api-1.0-sdk-1.7.7-1" and second folder as "appengine-api-1.0-sdk-1.7.7-2".
4) make sure you have jdk installed. e.g. "C:\Program Files\Java\jdk1.7.0_17\bin". set it to environment so you can run the file from that bin folder.
5) IMPORTANT: you must go into that first "appengine-api-1.0-sdk-1.7.7-1" folder and not at the parent folder of those folders.
6) launch cmd.exe and type "jar cf appengine-api-1.0-sdk-1.7.7-1.jar *" for the first archive.
7) do it again the same for the second archive (repeat step 5 and step 6).
8) go to \war\web-inf\libs folder, delete the existing appengine-api-1.0-sdk-1.7.7.jar.
9) copy and paste the appengine-api-1.0-sdk-1.7.7-1.jar and appengine-api-1.0-sdk-1.7.7-2.jar into \war\web-inf\libs folder.
10) now deploy it. it should work like charms!
EDIT:
Spelling correction.
Using that instruction :
To clarify, we're going to release a minor update for 1.7.7. For the
meantime, you can re-jar the file as follows:
cd to the working directory
$ jar xf somewhere\appengine-java-sdk-1.7.7\lib\user\
appengine-api-1.0-sdk-1.7.7.**jar
$ jar cfm somewhere\appengine-api-1.0-sdk-1.7.7.**jar META-INF/MANIFEST.MF *
and replace the old jar with the newly created one.
from http://www.mail-archive.com/google-appengine#googlegroups.com/msg67954.html
and the messages from the solutions here, I was able to make it work like this :
Open a command line and go into the bin directory of your JAVA installation where the jar.exe file is
cd "C:\Program Files\Java\jdk1.7.0_17\bin\"
Then, you need to find the file "appengine-api-1.0-sdk-1.7.7.jar" somewhere on your computer. It's at 2 places (not counting the temp directories), in the \war\WEB-INF\lib folder in your eclipse project and also in the "plugins" folder of your eclipse installation. Precisely there : \plugins\com.google.appengine.eclipse.sdkbundle_1.7.7\appengine-java-sdk-1.7.7\lib\
You just need one of those 2 paths.
Now in the command line, just type :
jar xf "C:\whatever-folder-your-eclipse-is-in\plugins\com.google.appengine.eclipse.sdkbundle_1.7.7\appengine-java-sdk-1.7.7\lib\user\appengine-api-1.0-sdk-1.7.7.jar"
and then
jar cfm "C:\whatever-folder-your-eclipse-is-in\plugins\com.google.appengine.eclipse.sdkbundle_1.7.7\appengine-java-sdk-1.7.7\lib\user\appengine-api-1.0-sdk-1.7.7.jar" META-INF/MANIFEST.MF
Now, if you go to that folder and check the .jar file, it should now be 11 mb instead of 30 something. Now you need to copy this one and replace the same jar in your webapp folder in \war\WEB-INF\lib\ so that both jars named "appengine-api-1.0-sdk-1.7.7.jar" have a 11 mb size.
Now the error should be gone and you don't have to split anything.

Why won't drjava allow me to create a jar file?

I'm making a JApplet and need to make a JAR file to connect to a .htm file with the applet tag. The simple solution I could think of was to use the tool in drjava that says "Create Jar File From Project..." but alas, it's not highlighted for some reason, so I can't do that. What I'm really looking for is either (a) an explanation as to why drjava can't turn my classes into a jar file, (b) an alternative to allow me to create this jar file, or ideally (c) both. Thanks for your help ahead of time.
I don't use Drjava, but here is how you can create a JAR file from the command line without any IDE specific complications.
Simply go to the folder/directory where your project is located. Let's say your class files are located in the bin folder. You can then use
jar cvf myapplet.jar -C bin .
The JAR is then ready to be deployed.

How to determine branch name from batch file

I did a get latest from TFS.
My local path is:
C:\tfs\Project\Branch1\Config\Deployment\CopyInstallers.bat
TFS Path is:
$\Project\Branch1\Config\Deployment\CopyInstallers.bat
CopyInstallers.bat gets latest of installer folder from the branch at different location on the server and zips them and puts it on the shared location on server.
I have another branch named Branch2 and its TFS path is
$\Project\Branch2\Config\Deployment\CopyInstallers.bat
What I am trying is try to get the branch name using TF.exe or TFPT.exe, so that I should not har code the branch name in the CopyInstaller.bat file to get latest of installer folder.
Or is there any other way by which I can get to know the branch name / path with in the batch file?
Use the TF.EXE info command.
From the DOS Shell go to the directory in your workspace where the branch is located (C:\tfs\Project\Branch1\Config\Deployment)
Use the command : TF.EXE info .
Parse the result on the "Server Path:" line.
EDIT :
With Visual Studio 2010 replace the info command by the properties one
EDIT 2
Ok: I made you a console app, get the zip file here, there's the sources code and build exe.
Tell me if it's what you expected

How to package IeEmbed.exe and MozEmbed.exe into an executable Jar file

I use JDIC in my executable Jar file, when it runs, it needs to have IeEmbed.exe and MozEmbed.exe in the same dir as the Jar file, I wonder if there is a way to package all 3 files into a single executable Jar file, so when I distribute the app, there is only one executable Jar file to worry about, besides, there are problems sending and downloading *.exe files, what's the solution ?
For instance, my executable Jar file is called Java_App.jar, how to get <1>IeEmbed.exe <2>MozEmbed.exe and <3>Java_App.jar into a Jar file called : My_App.jar, and when user double clicks on My_App.jar, it will run the Java_App.jar and find the needed IeEmbed.exe and MozEmbed.exe files from inside the My_App.jar package without unpacking and save them into a local dir.
There is no problem packaging them together per se. The jar file is finally a .zip file.
The problem will come when your app try to load it because it won't be able to find the .exe in the system path.
The solution is to make an installable file ( which can be a .zip file ) and expand and copy the .exe file for you for instance in a "bin" directory

Resources