Permissions in Windows 7 java unrecognizable in batch - java

I wrote a program to make a graphical Timeline and it works through some VBA and Java through the shell, but after transfering it over to Windows 7 from Vista I cannot seem to find a place to save the files so that the java program can access them. Please Help me. Where can I save the files such that I can have the java program access them and not throw an exception and blow up the program?
Update Now whenever I try to shell the java program I get a file not found exception runtime error 53 and it's on the shell call
Error that appears after calling java out of batch out of vba out of excel
Some reason it won't let me do this.

If you're targetting Windows Vista/7, you can build an EXE from a JAR file that has a certain manifest in it that makes the EXE require admin rights. This way, file I/O will always execute with the correct userrrights!

Related

Anylogic: Error when run a model as standalone Java application

I want to export my model as a standalone java application. When I want to run .bat file (my OS is windows 7), the following error appears; it says that it can not create Java virtual machine and the error which is given is about illegal access: deny.
what should I do?
And is there any other way to run a model on a computer where anylogic is not installed?
thanks in advance.
What version of AnyLogic are you using? This option has been taken care of in the latest versions of AnyLogic.
Simply delete the following line in the .bat file
set OPTIONS_XJAL=--illegal-access=deny
Or something similar related to the option --illegal-access=deny
Depending on what Java version you are using this option might not be available. Most models (depending on what Java functions you use in your model) should run just fine. If they don't you need to check the error that they give and investigate further.
In the latest AnyLogic they handle this using the following code
set OPTIONS_XJAL=--illegal-access=deny
IF "%VERSION:~0,2%"=="1." set OPTIONS_XJAL=

How to get java's execution data using javaagent

I am doing something about getting execution logs form a java program. But I just achieve this when it's a jar file using command like java -javaagent:agent1.jar -jar MyProgram.jar . But if there is a software which don't need using java -jar to open , how can I use my agent1.jar to get its execution data ? For example, I made a game by java ,and I open it by opening the file MyGame.exe ,which mean that I can't use javaagent:agent.jar to instrument and get logs.
Are there any ways to solve this problem or any other tools can give me a reference?

Execute a java program on login

I need to write a program which executes
whenever some one logged In to the windows system.
It is for daily report generation purpose.
I have written the program but couldn't get how to execute it on user login.
All the help would really be appreciated.
EDIT most of the people suggesting that I should put file in startup folder, but startup files only execute if 'system started/restarted'... I need to run the program whenever a user login like if the computer is started but locked and then someone unlocks, this program should be executed.
Correct me if I am wrong.
If you are working on a Windows OS then you can create an executable jar file of your java.
In order to make it launch at login you need to include it to the windows startup list.
You can create a batch file (.bat) in which you put:
"<YOUR PATH TO JAVA>/javaw" -jar "YourJar.jar"
Add this .bat file to windows startup check this
Batch/CMD: Adding files to Startup list
Hope it helps !
Setup your java application to run as a windows service.I think this answer will help you.
Answer is here
Create a batch program and put it on startup that should start your target file to run what you want to do.....
batch code :
start java target.java
Must setup the path for startup b4 run....
#happy Dev: hope you already know how to make a .bat in windows, just create a bat file which has line to execute java. or for more help on this you can see:
http://introcs.cs.princeton.edu/java/15inout/windows-cmd.html
Just make sure you have java installed on that machine. and your environment variable is set for java other wise you have to provide the complete java bin path.
Regarding how to run on login. simple way to go:
for windows 7: start menu--> All programs--> find a folder name startup and right click on it. there you can see open for all users open it and place your file there. every time when some user login the bat file will be executed automatically. and remember this wont work on hibernate. or to open that location you can just go to:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
for Other OS path is almost similar with just a minor difference.
You can use Task Scheduler for Windows Platform and configure which file to call at Login Time.
C:\Windows\system32\taskschd is the location.
Create a basic Task or Create Task...... are the options.!!
You can schedule the time of your task to get executed.

Terminal vs Eclipse PosixFilePermissions

By running the same command from the Eclipse and from the command line I get 2 different results:
With Eclipse everything works fine, however with the command line I get the following error message:
PosixThing.java:17: error: error while writing PosixThing: PosixThing.class (Permission denied)
This error message does not appear if I run "sudo javac PosixThing.java".
As it if was not strange enough, the same code with a different file located in the same directory (Desktop) does not give me any problem. (I am talking about mere txt files just to test the PosixFilePermissions function).
I checked the file permissions and everything is -rw -rw -rw As well as the others'. Do not know why it happens only with that specific file.
Running on Ubuntu 11.10 jdk 1.7.
Any suggestion to what it might be?
It sounds like a file / filesystem permissions problem of some kind:
Check the owner, group and permissions for the file, and all directories on the file pathname.
Check that you are running Eclipse and your command shell as the same effective user.
Check that you are not attempting to write to some kind of "funky" file system; e.g. a Windows file system mounted on Linux, or a FUSE file system of some kind.
If you've got SELinux enabled, check that's not causing the problem. (That's unlikely.)
It is also possible that you are running different releases / versions of Java in the two contexts, or even that Eclipse's file system cache is out of sync. (It is not clear to me what contexts the code is actually running in.)

Javaw.exe won't run .jar file while java.exe will

I have a java app that I wrote. I am able to execute it using Ant and with "java -jar" from the command line. I want to be able to launch the file using "javaw.exe" (my app uses Swing). For some reason it doesn't seem to do anything (javaw starts for a second and then quits with no error that I can see). I tried running the same file on my Win XP computer using javaw and it executes fine. The other computer I am using it on is a Win 7 laptop.
Building on purtip31's comment ...
I expect that the problem is that some exception or error is occuring when you launch using javaw, but you can't see any diagnostics because they are going nowhere.
In the short term, redirect standard output to a file and look at what is being written.
In the long term, replace your "System.out" and "System.err" diagnostics with proper logging via a logging framework such as log4j, java.util.logging, etc.

Categories