w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Invoke Java program in Linux using "./"
Just create a script called hello, chmod it into executable, place it on a folder registered on your PATH environment variable, for example: $ echo '$JAVA_HOME/bin/java -jar /path/to/myjar.jar' > hello $ chmod a+x hello $ ./hello

Categories : Java

Java "NoClassDefError" while running the program on Linux
NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time. For example if we have a method call from a class or accessing any static member of a Class and that class is not available during run-time then JVM will throw NoClassDefFoundError. It’s important to understand that this is different than ClassNotFoundException which comes while trying to load a class at run-time only and name was provided during runtime not on compile time. Many Java developer mingle this two Error and gets confused. In short NoClassDefFoundError will come if a class was present during compile time but not available in java classpath during runtime. Normally you will see below line in log when you get NoClassDefFoundErr

Categories : Java

running linux command txl from java program
you can find here what every parameter in ls do: -c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise: sort by ctime in order to execute a program in java and wait for it to finish you can use this post

Categories : Java

convert a java program into a linux command
I thing this can be useful for your case: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/binfmt_misc.txt?id=HEAD

Categories : Java

Unable to the Linux Script for executing a Java Program
With your given classpath, Java is only going to look in the jar file. For it to find the class file outside of the jar, you have to modify your -cp argument: java -cp ./com/ug_ugbapi-all.jar:. com.QuoteTester $1

Categories : Java

In Linux launch a c program from Python handing the c program a large text string as an argument
You can pass it as an argument by just… passing it as an argument. Presumably you want to quote it rather than passing it as an arbitrary number of arguments that need to be escaped and so on, but that's easy with shlex.quote. For example: with open('bigfile.txt', 'rb') as infile: biginput = infile.read(2048) os.system('cprogram {}'.format(shlex.quote(biginput))) If you get an error about the argument or the command line being too long for the shell… then you can't do it. Python can't make the shell do things it can't do, and you refuse to go around the shell (I think because of a misunderstanding, but let's ignore that for the moment). So, you will need some other way to pass the data. But that doesn't mean you have to store it in a file. You can use the shell from subproces

Categories : Python

How can I change variable values of a java program through a web interface?
If all you want to do is pass in command-line parameters, that's what the (String[] args) parameter is for. This assumes that there isn't anything I'm unaware of which rules out this sort of thing in interwebs-land, since I don't really have any experience with applets and such. Assuming it is applicable to your application, when the program is called, add the parameters to the end, eg: java.exe myApp "blue" "20px" (or however web apps are invoked) would run the program with args[0] = "blue" and args[1] = "20px" I'm I'm off-base, and applets are totally different than what I am used to, feel free to ignore or chastise me at your leisure.

Categories : Java

Call java command line program from .net and return output of STDOUT to variable
Yes, use Process.StandardOutput (e.g., StreamReader.ReadToEnd among other possibilities). Be sure to set ProcessStartInfo.UseShellExecute to false, and ProcessStartInfo.RedirectStandardOutput to true.

Categories : Java

What's a good way to set up Closure Compiler on Linux? Or, where should Java .jar's live on a Linux?
If you using the java command directly, then you'll have to provide a path to the jar in question. It's probably easier to place the jar in one place and create a shell script that handles the invocation and jar path.

Categories : Java

How to get the amount of each program used in Linux?
Back in the day when a computer in every desk was only a dream, computers were too expensive and few companies could afford to buy one - so they just rent some computer time from a provider. My dumb terminal was connected to the host computer over a regular phone line using a modem, at the astonishing speed of 9.6 kbps. This was the era of Time-Share. From this time, Unix got process accounting. See the Enabling Process Accounting on Linux HOWTO.

Categories : Linux

How do you save and open a Java program with a Java program?
You can use http://commons.apache.org/proper/commons-exec/ to start processes from Java code. You should call the same things as you would form command line. (javac -cp... and then java -cp.. someclass)

Categories : Java

Java exceptions and program flow: how to know if the program will stop or continue after an exception is thrown?
It isn't executed because uncaught exceptions terminate the current thread(main thread in your case). test() throws a RuntimeException. Surrounding test() with a try-catch would catch the exception and allow your program to continue. try { test(); } catch(RuntimeException e) { System.out.println("test() failed"); }

Categories : Java

Changing dir to execute program in linux
I'm not sure what instructions you're following to get what you showed. There is no built-in function called cd or run in Python. You can call a program in a specific directory using the subprocess module: import subprocess subprocess.call("./program", cwd="/home/user/a/b") The cwd argument causes the call function to automatically switch to that directory before starting the program named in the first argument.

Categories : Python

how to run a python program in linux crontab?
You need a correction : * * * * * /usr/bin/python /home/prkumar/Desktop/python/sample.py to run it every minute. Your cron statement : 1 * * * * /usr/bin/python /home/prkumar/Desktop/python/sample.py would run it only at first minute of every hour eg 09:01, 10:01...etc. Hence, you will have to wait 1 hour to see the result.

Categories : Python

Program memory layout in linux
if I have an array allocated on the stack a pointer to the first element will also be lower > in value than a pointer to the second element ? It is not important "how" you allocate the array, you can increase or decrease the stack pointer, but as result you have address space reserved for the array. You can work with them in normal way, since the lowest adress is reserved for element 0. so my question is what is the correct memory layout for a process in Linux ? You can check it yourself. Insert somewhere into you program something like std::cin.get() to pause your program. Then run in a separate shell: ps aux | grep your_program_name cat /proc/<pid show by grep>/maps This prints the memory mappings of your process, where you can see where the heap, the stack and o

Categories : C++

Send Linux command from C program
The problem is that history is not a real command but a shell builtin. Thus you can't call it from a C program[1]. Depending on the shell the user is using, you can instead get the history from ~/.bash_history, ~/.zsh_history and so on. Note however that zsh only write to this file at the end of a session. [1] Well, you could theorically try system("bash -c history"), but you won't get the actual history because the builtin isn't run in the context of the current session.

Categories : C

Linux: No output from a program in a .sh script
It could be sending output to stderr. To account for this possibility, try wine Blockland.exe ptlaaxobimwroe -dedicated -port 30000 2>&1 >>consoleLog.txt The 2>&1 bit redirects stderr (file descriptor 2) to stdout (file descriptor 1). Then it redirects stdout (which includes stderr output now) to your log file.

Categories : Linux

standalone program for MEX file in linux
It was a bug in R2013a. I got an email from the matlab centre to replace the 'depfun.opts' file with a new version. you can find the 'depfun.pots' file in the attachment here in this bug report

Categories : Linux

How to build PIC controller program on Linux?
You're getting that message because your compiler doesn't define the __dsPIC30F3013__ preprocessor symbol for you. You need to find out what flag you need from reading the compiler documentation. To set it, you need to read the documentation for your IDE. You can use: gcc -dM -E - < /dev/null To print the predefined macros that your compiler is generating.

Categories : Linux

Program based on pipe in Linux
I think what you're looking for is: echo <number you want to use> (or output from program) | <program you want to pipe into> For instance: echo 5 | more which will simply display: 5 The "|" is your pipe; it redirects output from the left to the right connecting their standard streams, which usually does not include stderr. Hope that helps.

Categories : Linux

what is the best way to test the performance of a program in linux
In general measuring performance using a simple time comparison, e.g. endTime-beginTime is always a good start, for a rough estimation. Later on you can use a profiler, like Valgrind to get measures of how different parts of your program is performing. With profiling you can measure space (memory) or time complexity of a program, usage of particular instructions or frequency/duration of function calls. There's also AMD CodeAnalyst if you want more advanced profiling functionality using a GUI. It's free/open source.

Categories : Linux

screen capture program in C or C++ and Linux
How to capture screen with ffmpeg: Use the x11grab device: ffmpeg -f x11grab -r 25 -s 1024x768 -i :0.0+100,200 output.flv This will grab the image from desktop, starting with the upper-left corner at (x=100, y=200) with the width and height of 1024x768. If you need audio too, you can use alsa like this: ffmpeg -f x11grab -r 25 -s 1024x768 -i :0.0+100,200 -f alsa -ac 2 -i pulse output.flv So you can simply place this in capture.sh and run it from your code: #include <cstdlib> int main(){ std::system("./capture.sh"); } If you have to do it without calling external utilities, you can use libffmpeg directly.

Categories : C++

Linux - How to program for a touchscreen outside of X Windows
It seems that you are just seeing a regular event device. What have you done so far? You might try for example Using the Input Subsystem article on Linux Journal. What you should try at first should probably be: /* how many bytes were read */ size_t rb; /* the events (up to 64 at once) */ struct input_event ev[64]; rb=read(fd,ev,sizeof(struct input_event)*64); if (rb < (int) sizeof(struct input_event)) { perror("evtest: short read"); exit (1); } for (yalv = 0; yalv < (int) (rb / sizeof(struct input_event)); yalv++) { //if (EV_KEY == ev[yalv].type) printf("%ld.%06ld ", ev[yalv].time.tv_sec, ev[yalv].time.tv_usec, printf("type %d code %d value %d ", ev[yalv].type, ev[yalv].code, ev[ya

Categories : Linux

how to write a makefile in linux for a c program
When using a makefile, you also started using the -Wall -Werror flags. This is a very good thing. Now the compiler looks for more suspicious things in your program, and refuses to compile if it finds anything. This can be a great help in catching bugs. However, these warnings mean your program doesn't compile, and you'll need to fix them, by changing the code so that the compiler will be sure all is OK (as far as the compiler can check - of course the code can still contain bugs). Common issues are mixing different types and not paying attention to the const keyword. But for help with specific warnings, you'll need to show the warnings and the code. Or better - search for each of them in StackOverflow, and I'm sure you'll find good answers.

Categories : C

Passing Data from a Java program to a Python program and getting results back
Sounds like a job for Jython! Jython is an embeddedable Python runtime written in Java. As long as you don't need to run your Python script in another process (e.g., want to be able to kill it, may use lots of memory, etc.), this is the best way by far.

Categories : Java

Java UDP packets not reaching Server program from Client program
Sounds like network security configurations prevents you from receiving UDP packets. You need to configure your network such that it accepts UDP packets on the specified ports. Also, you have to configure your firewall to accept UDP packets on the specified ports as well.

Categories : Java

Hebrew data from RPG program to Java program incorrectly ordered
So I ended up finding out what was going on here and am answering my own question in case any one else ever runs into a similar issue. The Hebrew was being stored on the iSeries in code page 424. This is a Hebrew code page so all was well with the storing on the iSeries. We had some print drivers on the iSeries that were handling the Hebrew data correctly so I knew the issue had to be either on the transfer between the iSeries and Java or when we create the String of data in Java.It turns out that the iSeries was storing the Hebrew in print order so it was already in the order that I needed it to be to write it to the PDF. When we were transferring it to the Java program we were using an RPG character byte array. This character byte array will convert to Unicode when it is sent to th

Categories : Java

Linux C - implementing the ability that a program can update itself
What you're describing is very similar to the 80s-style of delivering Unix source code, popularized by the development of PERL. You use diff to get a record of changes between different versions of the source-code, then distribute this "patch" file, and use patch to perform the necessary modifications at the client-end. This doesn't address the network-communication or version-control issues. A possible downside is that a first-time download may need to apply many patches to bring the version up. This is often the case when investigating old source from nntp:comp.sources.unix.

Categories : C

statically compiling 32 bit program on a 64 bit linux machine
If you want to use your own compiled library in 32 bits mode (e.g. libevent) you should configure it with CC='gcc -m32' to have it compiled in 32 bits mode. If you want to have both 32 & 64 bits versions of the same library you should build the library twice, with different configure options (don't forget to make clean between builds), perhaps changing the --prefix or --libexec-prefix You could also consider having an entire 32 bits distribution in your chroot-ed environment (and then you'll need to bind mount some directories like /proc, /dev, etc...).

Categories : Linux

Clearing output of a terminal program in Linux C
Could you clarify the question. Its not so clear. Anyway, i tried answering for what is best expected here. printf("AAAAAAAAAAAAAA"); printf("BBBBBBBBBBBBBB"); printf("CCCCCCCCCCCCCC"); //printf("DDDDDDDDDDDDDD"); comment the last line or delete if you dont want to display in terminal. printf("xxxx") is the statement used for printing output in terminal.

Categories : C

Limiting the memory usage of a program in Linux
The fact that you’re using Wine makes no difference in this particular context, which leaves requirements 1 and 2. Requirement 2 – I do not want the process to crash once it exceeds the limit. I want it to use HDD page swap. – is known as limiting the resident set size or rss of the process, and it’s actually rather nontrivial to do on Linux, as is demonstrated by a question asked in 2010. You’ll need to set up Linux control groups (cgroups). Fortunately, Justin L.’s answer gives a brief rundown on how to do so. Note that instead of jlebar, you should use your own Unix user name, and instead of your/program, you should use wine /path/to/Windows/program.exe. Using cgroups will also satisfy your other requirements – you can start as many instances of the program a

Categories : Linux

How to call a program installed on linux from within python?
Guess the input file should be the filename sys.argv[1] and not the python handle to the file. (http://nebc.nerc.ac.uk/bioinformatics/documentation/blast/fastacmd.html) In other words, change astaseq = subprocess.call(["fastacmd","-i", file1, "-o",foutname]) to astaseq = subprocess.call(["fastacmd","-i", sys.argv[1], "-o",foutname])

Categories : Python

Socket program unable to POST - C (Linux)
In the line send(sockfd, option_value1, sizeof(option_value1), 1); sizeof(option_value1) will evaluate to the size of a pointer. Depending on your system this may or may not be 4 bytes. Thus you are sending only 4, or whatever your system's pointer size is, bytes of the string. To get the length of the string use strlen(option_value1). You can check what you're transmitting by using a program call WireShark. Its free and will be able to show you what's going on on your network connection... what you're sending and what you're receiving. WireShark will also tell you if the HTTP packets you're sending are malformed.... If the server is not responding to your program, is it responding to ping requests. This is a useful tool. If it is responding to pings then you can be more confident

Categories : C

set system date and time within c++ program in linux
The "invalid date" part is because it actually executes "date --set newdate". You want it to execute "date --set [value of newdate variable]". Change system("date --set newdate"); to string cmd = "date --set "; cmd += newdate; system(cmd.c_str());

Categories : C++

how to compile c++ program using boost/shared_ptr.hpp on linux with g++
Specify the directory that contains the boost directory that contains the header files. For example: boost installation: /home/user/boost_1_53_0/boost/shared_ptr.hpp to include: #include <boost/shared_ptr.hpp> to compile (note -I, not -l): g++ -I /home/user/boost_1_53_0 main.cpp -o main Note that there is no dynamic-linking required, as boost::shared_ptr is a template and is fully defined in the header file. If your compiler supports C++11, use std::shared_ptr<> instead (as commented by Roee): to include: #include <memory> // use std::shared_ptr<T> to compile: g++ -std=c++11 main.cpp -o main

Categories : C++

How to view x86 Assembly from C program with .bin extension - Linux
GCC is a compiler. What you're looking for is a disassembler. On linux, you can use objdump(1). An example (some objdump output snipped for ease of reading): $ cat example.c #include <stdio.h> int main(void) { printf("Hello, world! "); return 0; } $ clang -Wall -Wextra -O2 -o example example.c $ ./example Hello, world! $ objdump -d example | grep -A10 '<main>' 0000000000400500 <main>: 400500: 55 push %rbp 400501: 48 89 e5 mov %rsp,%rbp 400504: bf 0c 06 40 00 mov $0x40060c,%edi 400509: e8 e2 fe ff ff callq 4003f0 <puts@plt> 40050e: 31 c0 xor %eax,%eax 400510: 5d pop %rbp 400511: c3 retq 400512

Categories : Assembly

Java: use other program's static method's output in my program
No, you can't communicate return values across JVM instances. You must devise and implement a specific protocol that will pass the data. One simple option you have is writing to System.out in the subprocess, which will push the data into your is, so your bytes will end up containing what the subprocess wrote.

Categories : Java

How can i make the python program to check linux services
You could use the commands module to run the ps shell argument: import commands output = commands.getoutput('ps -A') if 'Httpd' in output: print("Httpd is up an running!") [edit] I just read up on the commands module, and although working fine, it seems to be deprecated since Python 2.6 and even removed in Python 3.x. So if you are on Python 3 or want to be ready for future porting to Python 3, you can use the subprocess module: import subprocess output = subprocess.check_output(['ps', '-A']) if 'Httpd' in output: print("Httpd is up an running!")

Categories : Python

How to trully bind key in python console program in linux?
Add: stdscr.nodelay(True) To the beginning of the program. Then getch will always return right away. It'll return -1 if the user hasn't pushed anything since last time you called getch.

Categories : Python

Exception rised when runing jnotify program in linux
http://www.coderanch.com/t/377174/java/java/java-library-path The environmental variable name is platform specific On Windows you set PATH (don't actually remember how to set a windows env variable) On Linux you set LD_LIBRARY_PATH export LD_LIBRARY_PATH=jnotify-lib-0.94/64-bit_Linux/ On OSX you set DYLD_LIBRARY_PATH export DYLD_LIBRARY_PATH=/common/bryan_scratch/poc/poc_vips/project/src/.libs To avoid this issue, it is much better to use the Java command flag instead, as it is platform agnostic, i.e. java -Djava.library.path=jnotify-lib-0.94/64-bit_Linux org.blah.MyMain

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.