I want to run a jar with file names as arguments. for eg.
java -jar xyz.jar "C:\files" where "C:\files" directory contains all the files.
Can anybody help me with this?
What does the main class in the xyz.jar do?
Does it main method accept file names as arguments?
Does it understand that if the argument is a directory name, it needs to get the list of files in the directory and perform the operation on them instead?
Related
I successfully sourced a cpp file into the R environment using sourceCpp('my_cpp_code.cpp'), but I removed the 'my_cpp_code.cpp' by mistake. It is possible to recover the source code of my_cpp_code.cpp from the R environment?
The temporary directory of your R session (tempdir()) will contain a folder named sourceCpp-<architecture>->Rcpp-version> with sub-directories named sourcecpp_<random>. One of these will contain your code (plus the autogenerated code).
Maybe. sourceCpp() has a cacheDir argument (defaulting to getOption("rcpp.cache.dir", tempdir())) that specifies a location under which intermediate files, including the original source file, are saved. If the directory hasn't been cleaned up, you should find a folder there named "sourceCpp-<platform-info>" and under there, directories for each sourceCpp call you have done: these will contain the original file.
I need to write names of files in a folder. I am using Python 3.4.3 and I don't know how can I cause to write names of files in a folder
You can use os.listdir(path)
From the docs:
Return a list containing the names of the entries in the directory given by path...
I want to create a command that runs an executable created by compiling a c program. I couldn't find a proper solution. Let's say I have a file named myprogram.c and compile it and have myprogram as . I want to type myprogram in any folder in my system and run it. How can I achieve this?
First find out what your PATH is
echo $PATH
For you this outputs
/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin/usr/X11R7/bin:usr/X11R6/bin:/usr/local/sbin:/usr/local/bin
Then assuming your program is in the /usr/myprog directory, append /usr/myprog to your PATH (don't forget to separate directories with a colon :)
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin/usr/X11R7/bin:usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/myprog
Doing this tells the system when you don't specify an absolute path (like ./myprogram) to look in all the directories in PATH. It is good to add the absolute path of your executable to PATH because adding . to your PATH is frowned upon by some (see this question).
You have to add it in your PATH from your shell rc file
You place the executable into a directory that your shell already searches for programs, or you add your program's location to that list.
the $PATH environment variable contains this information. You can add myProgram's location to it, i.e. export PATH=$PATH:/new/dir, or just print out $PATH and copy myProgram into one of the paths listed there already.
I'm using Atom 1.0.5. I'm trying to create atom package.
I would like to get files name under the workspace.
Is it possible?
dirs = atom.project.getDirectories()
for dir in dirs
for entry in dir.getEntriesSync()
console.log entry.getPath()
You should be able to use the following two APIs:
Project.getDirectories: Get an Array of Directorys associated with this project.
Directory.getEntries: Reads file entries in this directory from disk asynchronously.
So you would use Project.getDirectories first to get a list of directories, and then iterate through them using Directory.getEntries. Each entry can either be a file or a directory (again).
I have a program that creates java source code files, compiles them to create class files and “jars up” the classfiles into a jar using java.utils.jar. When the resulting jar is placed in a lib directory in another application, the classes are supposed to be recognized. Except the created classfiles are not being recognized. So I used WinZip to zip the same class files, renamed the “zip” a “jar”, placed the new jar in the lib directory and the files are recognized fine. Used WinZip to look at the first (programmatically-produced) jar and the WinZip-created jar and they look identical. Same paths, same original size, same compressed size. Also tried creating a zip via java.utils.zip and renaming it. Same problem. Does anyone know of any reason why the programmatic zip/jar files could not be recognized by the Java class loader?
Solved. Maybe this will help others. The argument to ZipEntry (and JarEntry) must use forward slash ("/") as the name separator in order for the ClassLoader to correctly recognize the included files. In particular, other separators, such as those returned by File.getAbsolutePath(), while seemingly happily accepted by java.utils.jar and WinZip, will not be recognized by the ClassLoader.