Help coderanch get a
new server
by contributing to the fundraiser

Lakshan Dissanayake

Ranch Hand
+ Follow
since Oct 26, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Lakshan Dissanayake

Tim Holloway wrote:Actually, I think there's supposed to be a "working directory" directive for that desktop link file, so that would eliminate the need for the "cd" command in the Exec directive.

Note that "/opt" is supposed to be a shared system directory, so it's not er, optimal, for use as a single-user app.

In fact, if you want multiple users to have the ability to use the same app, you can put the executable in /opt - preferably a subdirectory of /opt, but you should use the Java Preferences system if you need per-user files.

Probably even better would be to put the Java app under /usr/local (or /usr/local/bin*), use Java Preferences for per-user data, and put any common data files under /var/lib. And while you're at it, add a shell script to run the java -jar command so that the Exec is more Linux-friendly.


*Note that there are attempts being made to reduce the number of "bin" directories in Linux, so check current recommended practices in the LSB.



Thanks Tom!
6 years ago

Campbell Ritchie wrote:. . . and what is wrong with keeping your .jar somewhere in /home? Your desktop link shou‍ld work nicely however.



found a working solution with the help of a friend (Rob Brew)

[Desktop Entry]
Version=1.0
Name=My Software
Exec=bash -c 'cd "/opt/myJavaProgram" && java -jar myJar.jar'
Terminal=false
Type=Application


Thanks Rob & Campbell Ritchie!
6 years ago

Campbell Ritchie wrote:Why are you running your work from /opt rather from a home directory?



I need to create a desktop shortcut entry and here is how its looks like

[Desktop Entry]
Version=1.0
Name=My Software
Exec=java -jar /opt/myJavaProgram/myJar.jar
Terminal=false
Type=Application


anyway Thanks Campbell Ritchie!
6 years ago

Rob Spoor wrote:That's because . is the directory where the program was started from - /opt/myJavaProgram in your first example, and your home directory (~) in the second.



Thanks Rob!  

But i was looking for something like to force java or program to consider relative path from it's jar location.

Anyway thanks for your time Rob

-supun
6 years ago
Please note

if i run the jar file using java -jar myJar.jar it works fine
and it will NOT work if i use java -jar /opt/myJavaProgram/myJar.jar


supun@supunz /opt/myJavaProgram $ java -jar myJar.jar // this works fine

supun@supunz ~ $ java -jar /opt/myJavaProgram/myJar.jar //this is not
6 years ago
Hi folks, i made a java programs which uses some files for its execution



I created a jar file and i put the jar file and above mention report file in /opt/myJavaProgram/

my directory tree is like follows
/opt/myJavaProgram/myJar.jar
/opt/myJavaProgram/reports/myReport.jrxml


now is the question
if i run the jar file using java -jar myJar.jar it works fine
and it will NOT work if i use java -jar /opt/myJavaProgram/myJar.jar

i guess that is because working directory related problem. but i cannot figure out how to get rid of it

any idea to solve that?
Thanks in advance!

-supun
6 years ago

Rob Spoor wrote:There is no such thing as a Class object for a generic type. There is only Response.class for the raw Response type. However, you can still do what you want with a little bit of cheating:

You can't cast Response.class directly to a Class<Response<RESULT>>, but the intermediate cast solves that.[/quote

Thank you very much Rob!
You're life saver

7 years ago
Hi folks,

I'm doing some robospice stuff in android and got strucked in class type retrival



i also tried following to use instead for Response and there was no luck because Response doesn't have a public constructor


Any help would be greatly appriciated!

Thanks!
-supun
7 years ago

Campbell Ritchie wrote:That is no different from <T> String or <T> int before the method name. It is a generic method and you can read about it in the Java® Tutorials.



Thanks Campbell Ritchie!
9 years ago
Hi folks,

I dig some tutorials and found a strange method


what is special about <T> void?
I can understand meaning of following.


Thanks in advance!
9 years ago
It seems like is null.
It's bit hard to make a guess.
If you can send source code, I hope I'll be able to help you to solve this problem.
please check your private messages for my email address.

-Supun
9 years ago
why did you use something =="1"

If you want to check the equality of two strings you should use equals method

Pay attention to following example



find out WHY position 1 gives true
Google it
You will find the answer, trust me ;)
10 years ago
Hi folks!,

I am new to reporting in android.
I need to print a report(like sales bill).
I did some research and found something relative with JasperMobile.
Note: I can get a print using byte array with bluetooth printer.

But No idea how to use it.

Please suggest me tips to achieve my goal.

Thanks in advance!

-Supun
10 years ago

Campbell Ritchie wrote: . . .
So, how are you going to use ZERO in class Bar. You either have to use the old‑fashioned technique of writing Foo.ZERO, or write plain simple ZERO, which requires a static import.

At least I think it does; I have never tried. Try it and tell us what happens.



Yeah that works. but in my problem so no need of static import.

anyway thanks for your help.
10 years ago

Campbell Ritchie wrote:You would still need a static import even if the classes are in the same package.



Why? there is no need of that.
10 years ago