I recently decided to use an official installer for my Java application.
The application installs its self in the appropriate folder under the Programs Files.
Inside the bin folder where the jar for my application sits, I have a h2.db file which contains a bunch of information that is read by the application.
When I try running the application in the installed location I get an exception:
org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.FileNotFoundException: C:\Program Files (x86)\Aurora Game Hub\bin\AuroraDB.lock.db (Access is denied)"; "C:/Program Files (x86)/Aurora Game Hub/bin/AuroraDB.lock.db" [90031-167]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:158)
at org.h2.message.DbException.convertIOException(DbException.java:315)
at org.h2.store.fs.FilePathDisk.newOutputStream(FilePathDisk.java:265)
at org.h2.store.fs.FileUtils.newOutputStream(FileUtils.java:223)
at org.h2.store.FileLock.save(FileLock.java:197)
at org.h2.store.FileLock.lockFile(FileLock.java:333)
at org.h2.store.FileLock.lock(FileLock.java:128)
at org.h2.engine.Database.open(Database.java:542)
at org.h2.engine.Database.openDatabase(Database.java:222)
at org.h2.engine.Database.<init>(Database.java:217)
at org.h2.engine.Engine.openSession(Engine.java:56)
at org.h2.engine.Engine.openSession(Engine.java:159)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:138)
at org.h2.engine.Engine.createSession(Engine.java:121)
at org.h2.engine.Engine.createSession(Engine.java:28)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:305)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:72)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at aurora.engine.V1.Logic.ASimpleDB.searchAprox(ASimpleDB.java:828)
at aurora.V1.core.GameSearch.searchGame(GameSearch.java:249)
at aurora.V1.core.GameSearch.run(GameSearch.java:346)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\Program Files (x86)\Aurora Game Hub\bin\AuroraDB.lock.db (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.h2.store.fs.FilePathDisk.newOutputStream(FilePathDisk.java:257)
... 22 more
It works fine when its not in the Program Files location, as I would have noticed this while developing.
i'm thinking it has something to do with permissions and the lock file not able to be created or something. Is there a way to give/ask explicit permission to create the lock file or can I tell H2 to just not create the lock file?
We've thought about having the static database placed somewhere other then the install location, but since this has to run on Mac and PC and the way the installer is set up it would make things more complicated.
Any help would be very much appreciated.
It seems there are no access rights to write to this directory. You need to store the database file in a directory where you do have access rights.
For H2, if you use the database URL jdbc:h2:~/data/db, the database is stored relative to the current user home directory. Another alternative is to use an absolute path, for example jdbc:h2:c:/dir/to/db/file
This is caused by improved security in windows. You can write only when you have elevated privilages. For example if you start program as 'run as administrator', then it may able to write to Program Files area. Then it is not a good idea- see: Bypass Windows permission restrictions on program files folder
You should use folder pointed by 'ProgramData' variable. or good old user.home area
On Mac OS X, you can use the known subdirectories of user.home cited here.
Java Web Start with suitable permissions may be an alternative, although I haven't tried it.
Related
when I tried to run weka 3.8.6 the Error is
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at weka.gui.SplashWindow.invokeMain(SplashWindow.java:306)
at weka.gui.GUIChooser.main(GUIChooser.java:92)
Caused by: java.lang.IllegalStateException:
java.io.IOException: Unable to create the metastore directory: C:\Program Files\Weka-3-8-6\wekaMetaStore
at weka.core.Settings.<init>(Settings.java:134)
at weka.gui.LookAndFeel.setLookAndFeel(LookAndFeel.java:151)
at weka.gui.GUIChooserApp.main(GUIChooserApp.java:1663)
... 6 more
As tgdavies pointed out, the currently logged in user does not seem to have write permissions to the C:\Program Files\Weka-3-8-6 directory.
Did you create a WEKA_HOME environment variable and pointed it at the C:\Program Files\Weka-3-8-6 directory? By default, this variable would point to %USERPROFILE%\wekafiles under Windows and $HOME/wekafiles under Linux/Mac.
The WEKA_HOME directory is not Weka's installation directory with the executables, javadoc, etc, but the directory where Weka will look for packages, props files, store its log files, etc.
You should create a directory in your home directory (your user would have write access there) and then point the WEKA_HOME environment variable to that directory. Once that is done, try starting Weka again.
Note: This question was originally titled "How can I reset the path of FFMPEG in Java?" but, as it has been pointed out in the comments and the answer, the issue is not with Java, so I've changed the title to make it easier to find for others with the same issue.
I accidentally set the path for FFMPEG to a different folder, and I can't change it back.
I'm using Processing (the library and its IDE) and the user-created Video Export library to capture and write to an mp4 video file. The library required FFMPEG, so I downloaded and installed it. After I installed it, I ran the code, and the library called Java to request the path of FFMPEG. I wrongly set the path to a different folder (which I eventually deleted), and immediately realized my mistake. I ran the code again to see if I could trigger the prompt again to correct the path.
The console response I received was: (I'm sure most of it doesn't have to do with the actual issue. However, I wanted to show all of it in case it somehow does.)
Oct 24, 2016 10:23:25 PM java.util.prefs.WindowsPreferences
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs
at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
java.io.IOException: Cannot run program
"C:...\Processing\Octree_Graphics\data\FFMPEG\ff-prompt.bat":
CreateProcess error=2, The system cannot find the file specified at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at
com.hamoid.VideoExport.startFfmpeg(Unknown Source) at
com.hamoid.VideoExport.initialize(Unknown Source) at
com.hamoid.VideoExport.saveFrame(Unknown Source) at
Octree_Graphics.draw(Octree_Graphics.java:90) at
processing.core.PApplet.handleDraw(PApplet.java:2399) at
processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:731)
at
jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
at
jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
at
jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
at
jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759) at
com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
at
com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
at java.util.TimerThread.mainLoop(Timer.java:555) at
java.util.TimerThread.run(Timer.java:505) Caused by:
java.io.IOException: CreateProcess error=2, The system cannot find the
file specified at java.lang.ProcessImpl.create(Native Method) at
java.lang.ProcessImpl.(ProcessImpl.java:386) at
java.lang.ProcessImpl.start(ProcessImpl.java:137) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 17 more
VideoExport error: Ffmpeg failed. Study
C:...\Processing\Octree_Graphics\basic.mp4.txt for more details.
I need to find a way to reset the path of FFMPEG that Java has. I have tried uninstalling and reinstalling the library, but I haven't tried Java (I don't want to mess with anything it has in its current state).
Firstly, from what I can tell, this is merely inside the library in Processing, not inside of Java itself.
I have found you can reset the ffmpeg directory by running the
".forgetFfmpegPath();" method on the VideoExport object. You only need to run it once then you can remove it.
Inside the Video Export docs the method has the description "Makes the library forget about where the ffmpeg binary was located."
You can find the documentation of the method in the VideoExport documentation, which can be found in the Processing IDE at "Help -> Libraries Reference -> Video Export". (Note the VideoExport library must be installed)
I understand this is two years old, but I am here for other people who have this issue.
I just had this issue and found this question, but there was no answer, so I am giving the answer I found worked.
I was wondering if someone could help me find a good resource to help me fix this issue. I'm trying to create/save a batch file in the startups folder. Here's the general path: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\startup_PMA_popup_check.bat
I've read a lot of things saying that I should simply elevate the privileges of my java program.
I read that if I was to make my jar file a windows executable, then the rights of the program are automatically elevated to admin privileges.
What you're seeing below is my jar turned into an exe and run. The error I got was the same error as the one I got from running my jar. I no longer think that the problem is simply giving my program admin privilege.
I performed a test outside of my program by going to this path and attempting to move a file into the folder. Assuming I'd have no issue "since I am root already", I went ahead expecting to get no prompts. What I got was a popup saying that I needed to confirm that I was Admin & to confirm that I wanted to put the batch file in the folder.
My question is how should I make my java program issue this prompt to the user or something so my program can continue & not crash like shown below??:
Exception in thread "main" java.io.FileNotFoundException:
C:\ProgramData\Microsoft\Windows\Start
Menu\Programs\StartUp\startup_PMA_popup_check.bat (Access is denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at java.io.PrintWriter.(Unknown Source)
at java.io.PrintWriter.(Unknown Source)
at prioritymanagementassistant.Background.createBatchFile(Background.java:106)
at prioritymanagementassistant.Main.main(Main.java:930)
Thank You for your time,
Can you please tell me the solution to fix this below issue ---
This Exception I am getting while trying to connect SAP related files through Java class even though sapjco3.jar is in my library path.I tried this in Windows XP & Windows Server 98.
java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at com.sap.conn.jco.rt.DefaultJCoRuntime.loadLibrary(DefaultJCoRuntime.java:441)
at com.sap.conn.jco.rt.DefaultJCoRuntime.registerNativeMethods(DefaultJCoRuntime.java:307)
at com.sap.conn.jco.rt.JCoRuntime.registerNatives(JCoRuntime.java:987)
at com.sap.conn.rfc.driver.CpicDriver.<clinit>(CpicDriver.java:948)
at com.sap.conn.rfc.engine.DefaultRfcRuntime.getVersion(DefaultRfcRuntime.java:43)
at com.sap.conn.rfc.api.RfcApi.RfcGetVersion(RfcApi.java:259)
at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:200)
at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:73)
at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
at com.sap.conn.jco.rt.RuntimeEnvironment.<init>(RuntimeEnvironment.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.sap.conn.jco.ext.Environment.getInstance(Environment.java:121)
at com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(Environment.java:216)
at de.vogella.sap.rfc.core.connection.Connection.<init>(Connection.java:37)
at struct.actions.GestReservaSap.<clinit>(GestReservaSap.java:63)
at eu.sony.com.moduloreservas.ReservasMainClass.main(ReservasMainClass.java:259)
The SAP Java Connector internally uses a native library to connect to SAP. This native library is not the sapjco3.jar but the sapjco3.dll (on Windows systems). I.e. the dll file must be in a folder which is in your Java library path.
The latter is a Java system property, you can access it in your application by calling
System.getProperty("java.library.path")
Then you can put the sapjco3.dll either into one of the folders which are already in your library path (on Windows e.g. something like C:\WINNT\system32) or the other way around set the library path to a specific folder by explicitly setting the library path:
in the application code by setting
System.setProperty("java.library.path", "C:\path\to\folder\with\dll\")
before accessing the SAP JCo
or when starting Java with the command line argument
-Djava.library.path=C:\path\to\folder\with\dll\
Since putting the dll into a system specific folder like winnt\system32 may have effects not only to your application but to others as well, it is recommended to add the folder containing the sapjco3.dll to your application's library path. The more flexible way is to specify it via the command line as shown above so you don't have it hard coded.
Sorry for this question but I'm a newbie to Java. I tried searching for similar problems, and I did find some answers, but none worked in my case, so here it goes:
I'm trying to load a java applet on a web page. The applet is supposed to be loaded from a .jar file (UCFApplet.jar), but I cannot get it to load no matter what.
Here's the html for the applet:
<applet id="UCFApplet" height="200" width="200"
code="com.fujitsu.test.applet.UCFApplet"
archive="UCFApplet.jar">
</applet>
The jar file is on the server, on the same folder than the html file that is trying to load it. Inside the jar file there's a UCFApplet.class file on com/fujitsu/test/applet folder.
The error I'm getting on the Java console is the following:
Java Plug-in 1.6.0_29
Using JRE version 1.6.0_29-b11 Java HotSpot(TM) Client VM
User home directory = C:\Users\PTMAIAJ
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
load: class com.fujitsu.test.applet.UCFApplet not found.
java.lang.ClassNotFoundException: com.fujitsu.test.applet.UCFApplet
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.ClassNotFoundException: com.fujitsu.test.applet.UCFApplet
As you can see, I'm using jre 1.6.0_29 build 11, which, from what I get on the Oracle page, is the latest build. This happens on all browsers (IE 9, FF, Chrome).
I suspect it may have something to do with not being able to access the .jar file because if I change the html code to a dummy name such as archive="thisFileDoesNotExist.jar" it gives me the same error. But I don't really know what to put there in order to make it work.
Any idea about what I can be doing wrong ?
Thank you and best regards,
Joao Maia
Your descriptor seems to be correct, so try the following.
First check that browser can download the jar. Type the direct URL to jar file into your browser. For example if your html can be accessed by typing
http://localhost/myapp/mypage.html
type
http://localhost/myapp/UCFApplet.jar
If you can download the jar and it is identical to your jar continue.
Check the jar itself. Type in command line
jar vft UCFApplet.jar
and see output. You should be able to find your class:
/com/fujitsu/test/applet/UCFApplet.class
BTW do you know that applet tag is deprecated and is not supported by Opera and Chrome? To support all browsers you should use tag object
Try turning on tracing in the java control panel. It will then produce a log file in the following path that may help:
%USERPROFILE%\AppData\LocalLow\sun\java\Deployment\log
In my case I had an error which only appeared when I turned on tracing, and which presented as simply a "ClassNotFoundException":
java.util.zip.ZipException: duplicate entry: META-INF/LICENSE.txt
The applet loader was rejecting the jar because the zip file had a duplicate file entry. Strangely appletviewer.exe was able to load and run this jar fine.
For those of you running behind a corporate proxy. According Oracle ClassNotFoundException is "a common error that is seen if the proxy settings are not correct".
See: How do I configure proxy settings for Java?