Struggling to create a desktop shortcut for a jar file.
Found a solution which created a .url file aka
[InternetShortcut]
URL=D:/test.jar
which worked pretty well. But then the stakes went higher and now i need to run in from a certain JRE. Basically, what i'w tried, was to fix the URL to %javapath%/java.exe -jre d:/test.jar, but Win7 started to treat it as a web-url, adding a "http://" at the start of the url when looking through file properties.
Is there a way to make this work? Or maybe a freeware library that can create urls in a more graceful way?
Upd: Finally struck on an answer(and yes, i found in on stockoverflow) - Creating a shortcut file from Java
If someone gets here, looking for the answer:
ShellLink sl = ShellLink.createLink("C:/Program Files (x86)/Java/jre1.8.0_121/bin/javaw.exe");
sl.setCMDArgs("-jar D:/Test1.jar");
Related
Getting the below error when trying to initiate call.
<SIP/xx.xxx.xxx.xx-00000000>AGI Rx << VERBOSE "No script configured for URL 'AGI://localhost/xxx.agi' (script 'xxx.agi')" 1
Can anyone help me to resolve this error.
Thanks
This is already old, but still i got stucked yesterday with same issue, and found the solution.
A lot of people saying about the classpath where your properties file should be, and they are right.
As long as you running the asterisk jar in terms to run the test script, it doesn't have the properties file inside with YOUR script pointed there. So you need to direct it.
Try to use this command, but modify it with your path:
java -cp /home/your user/folder with project/src/main/java/:/home/your user/folder with jar file placed/asterisk-java-2.0.2.jar org.asteriskjava.fastagi.DefaultAgiServer
org.asteriskjava.fastagi.DefaultAgiServer - this is the path which you use to run a server. Even if you will write something like:
java -jar asterisk-java-2.0.2.jar
it will call the DefaultAgiServer anyway.
So my point is, that the classpath here is a keyword, and command above will solve this problem for sure =)
UPD: Although it fix the issue with classpath of .properties file, that doesn't mean that it will solve this problem, in case if your script placed in additional packages =)
If path to your script is something like
com.yourcompany.yourpackage.YourScript
that mean that you need write down the same thing in a properties. Something like:
hello.agi = com.yourcompany.yourpackage.YourScript
Hope this will help somebody ;)
This error is writed by your java code. See java code for more info about how to do call. Most likly need do something like
AGI://localhost/xxx.agi?function=func
I'm a java n00b, so please excuse any ignorance.
I'm trying to run a TestNG test in IntelliJ on OSX, but when I do, I get the following file not found error:
File: src/test/resources/manager/MemberTest/testCreating.csv not found.
However, when my colleagues run this on their Windows machines, the test completes and they do not get the same error. One such colleague's file was located at
D:\trunk_QA\src\test\resources\manager\MemberTest\testCreating.csv
Mine is located at
/Users/username/QA Materials/Automation/Framework/trunk_QA/src/test/resources/manager/MemberTest/testCreating.csv
The dataSourcePath seems to be correctly laid out as a relative path:
private static String dataSourcePath = "src/test/resources/";
And when run with that dataSourcePath, I get the error.
If I update it to use my local absolute path:
private static String dataSourcePath = "/Users/username/QA Materials/Automation/Framework/trunk_QA/src/test/resources/";
The test then passes. However, I can't check this in because outside of being a poor practice to use absolute links, it will break the test on my coworkers' machines.
What am I doing wrong? Do I need to define a system variable such as CLASSPATH?
To begin with I would suggest using File.separator instead of slashes as they will be guaranteed to be cross-platform.
If that doesn't make it work you could try this:
System.out.println(new File(".").getCanonicalPath());
That will print the actual directory you are in. Perhaps you are not where you think you are?
I figured it out. I had to edit the working directory under Run>Edit Configurations>TestNG. When I imported the project, it set that working directory all on its own, and to the wrong thing!
The reason it wasn't printing the user.dir when the dataSourcePath was set to src/test/resources/ is that it was erroring out before it hit that chunk of code.
Overall, a pretty simple solution if you know what you're doing with setting up IntelliJ.
Thank you to everyone for your help! I learned all sorts of new stuff.
I have a problem setting the library path for moyocore.dll in my jsf project, i have already tried to allocate the file in different folders and set different paths.
Outlook.setLibraryPath("C:\\Users\\irebollo\\Desktop\\plazos\\Java Outlook Connector\\lib\\moyocore.dll");
this one was working in a single java file, but when added the code to a bean function in my jsf project absolute route stops working, ok that was obvious but the problem is next
then I tried setting relative paths from my workspace like:
Outlook.setLibraryPath("\\lib-joc\\moyocore.dll");
Outlook.setLibraryPath("\\resources\\lib-joc\\moyocore.dll");
tried with "\" and "/" but still cant get it working.
I have to say that everything in the code is ok, the only problem is the path to the library but if someone needs to see the code i will post it.
moyocore.dll is allocated in /projectRoot/plazosExcel/WebContent/WEB-INF/lib
also in /projectRoot/web/resources/lib-joc/moyocore.dll
I'm not very skilled with JSF and it's folder structure so maybe i'm not putting it in the right place or not referencing it ok or both.
Additional information:
Path to workspace -> C:\Users\irebollo\Documents\NetBeansProjects\plazosExcel
OS -> Win7
IDE -> NetBeans8
I have googled it but there is no information about java outlook connector in jsf so I hope this big community can help me once again.
P.S: it's my first question so if i'm missing something or there is something wrong i'd appreciate to know it.
Ok I solved it, after adding the library to the windows PATH var and try tons of different locations i added this to the JVM options:
(included moyocore.dll in C:\lib previously)
-Djava.library.path="C:\lib"
That was yesterday, 10 mins ago I realized that JVM options dont need "" so i changed it and started to work.
Conclusion: I'm stupid, but I hope my struggle with JSF and JOC may be helpful for someone.
This question is over, can be closed or archived.
Update: The problem was solved with the help of MathWorks. I've published the answer below.
I need to control a program (Zemax) from Matlab. Unfortunately, Zemax only supports DDE for such control, which Matlab does not support any more. It works, but stops working on 64 bit platform after a few (presumable 63) DDE calls.
I wonder if there are working solutions. I could probably program a DLL with correct DDE support and then use DDE in Matlab via this DLL. This is a major effort for me. A more suitable solution would be to use Java DDE methods. Following another post here, I've discovered the JDDE library. However I cannot make it work: Even if I am in the directory with the DLL and JAR files, executing
import pretty-tools.JDDE-2.0.3.*
works fine but calling
a = com.pretty_tools.dde.client.DDEClientConversation()
afterwards (as done here) results in
Undefined variable "com" or class "com.pretty_tools.dde.client.DDEClientConversation".
I have very limited writing privileges on my PC, so I have added the javaclasspath.txt file with the jar/dll location to the directory indicated by prefdir. The file looks like this:
C:\Users\xxxxxxxx\Documents\matlab toolbox\jdde\pretty-tools-JDDE-2.0.3.jar
Calling javaclasspath shows a long listing with the last lines being:
...
C:\Program Files\MATLAB\R2012b\java\jarext\webservices\ws_client_core\mw-service-client-core.jar
C:\Users\kkarapet\Documents\matlab toolbox\jdde\pretty-tools-JDDE-2.0.3.jar
DYNAMIC JAVA PATH
<empty>
So path seems to be set correctly. What am I doing wrong?
With the help of MathWorks support, I've found the answer. Here is how to make JDDE work with Matlab 2012b, without admin privileges:
Download and unpack JDDE files (DLLs and JAR) into some folder. Let's say it's $path-to-jdde$\.
In Matlab, type prefdir. Open the resulting directory and create two files there, javaclasspath.txt and javalibrarypath.txt.
In javaclasspath.txt, add $path-to-jdde$\pretty-tools-JDDE-2.0.3.jar.
In javalibrarypath.txt, add $path-to-jdde$\.
Restart Matlab.
Now call ddeConv = com.pretty_tools.dde.client.DDEClientConversation; and start using the created object as described in JavaDoc. E.g. to connect to Zemax, run Zemax and then in call ddeConv.connect('Zemax', 'abc').
Step 2 above can only be done starting Matlab version R2012b. With an older version, if you have the write rights on the Matlab installation directory, you should be able to replace step 2 by editing the files librarypath.txt and classpath.txt in $MATLABROOT$\toolbox\local. I could not verify it so if you confirm it please let me know in the comment below.
I am working on a team project in Java. One requirement is that we dynamically populate a drop-down menu of all classes that implement a certain interface. New classes can be added after compile time. To accomplish this we are using reflection.
Problem: All of the drop-down menus are blank on my system. I cannot for the life of me figure out why they are not populating. All other 5 team members have it working on their system.
Things I tired that didn't work:
1) Installing most recent eclipse (galileo) because rest team was using it
2) Re-install most recent java release (jdk1.6.0-17 and jre6)
3) Check PATH and JAVA_HOME variables
Any thoughts as to what else I can try or if something I did should have solved it and didn't? It is driving me crazy.
Edit:
I should have been clearer that we are developing in a team. We are using SVN for version control and we are all running the exact same source code. I even tried checking out a fresh copy of the entire tree from SVN, but I had the same issue with reflection on my system while it worked for teammates.
The team created an executable jar and that ran on everyone's system fine except for mine. Everything worked for me except the reflection bit.
You need to debug your application. This means you have to systematically explore possible causes of the problem. Here are some things that come to mind:
Could your GUI be failing rather than reflection? What if you output with System.out.println() rather than your menu?
Is your reflection code throwing an exception, and are you ignoring it?
Is your reflection code actually being called? Toss a println() in there to be sure!
Is the test for the interface suffering from a typo or similar error that's causing it to fail? Try finding classes that implement Serializable instead!
Is your reflection test running in the main thread and trying to update your GUI? You need to use SwingUtilities.invokeAndWait to get an update to the Swing worker thread.
You're working with Eclipse; Eclipse has a fantastic debugger. Set a breakpoint near where your main action is and then single step through the code.
PATH and JAVA_HOME won't help. PATH only affects dynamically-linked libraries ("native code"). JAVA_HOME is a scripting variable that happens to be used by some Java-based utilities like Ant and Tomcat; it means nothing to the Java runtime itself.
You need to be investigating the classpath, which should be specified by the -classpath option to the java command, in the Build Path in your Eclipse project properties, or in the Class-Path attribute of the main section of a JAR file if you're launching java with the -jar option.
From within your code, you should be able to list the contents of your classpath by examining the system property, "java.class.path"
System.out.println(System.getProperty("java.class.path"));
Problem solution:
Classpath leading to source code must have no spaces in it.
I am running windows XP and, for whatever reason, if the classpath that leads to the jar file or source code that is using reflection has any spaces in it, then the reflection fails.
I took the jar file that works for the rest of my team and ran it from C:\ on my system and the reflection worked perfectly fine.
I do not know why this is so please comment if you know what is happening.
Might be a long shot, but look for differences in security settings for you and your team mates. Article describing more details http://www.ibm.com/developerworks/library/j-dyn0603/ heading "Security and reflection"