I am writing/planning to write a program that takes in a java file (or multiple java files), and edits and adds functions/classes/variables and then outputs a new java file (or multiple files).
Is there a C++ or Java library that
Can recognize and output names of classes/functions within a text file
Can recognize and output the names of the input arguments for said classes/functions
Can allow me to insert code at specific lines or within specific functions
Can search for a given variable name/value
Maintains original file formatting
I would prefer not having to manually code something to do the above, so any help would be appreciated.
Thank you in advance!
EDIT: I currently use Eclipse, and am unsure of how to proceed. So to further explain my question:
In eclipse, if I write a program that opens another .java file, How would I go about 'asking' eclipse to output, say, all the class names of the .java file I just opened?
Also I will explain the 'purpose' of this project to further clarify. I want to write a program that can take in any java file, and turn it into a class that can implemented remotely via RMI. To do this I will need to add an execute() function, have the file implement Task and Serializable and add a few variables, etc... Based on my knowledge, doing this in Eclipse would require manual editing of the program, but I would like to completely automate this process.
Thank you, again.
Much of what you need can be found in a modern IDE; and some very good IDEs are open source (eclipse and Intellij IDEA Community Edition for Java). You might look there to see if there are modules that suite your needs.
Looks like you are talking of a tool like eclipse. You might not be looking for a full fledged IDE, but the requirements that you have mentioned are fulfilled by any basic IDE.
If you wish to make one of your own, you can do that using eclipse rich client platform.
All that you would need from Java is the reflection API.
Related
I have been searching for this but I could use a bit of help. I am not even sure if a plugin is the way to go with this.
Anyway, here is a description of what I want to do:
I have developed a Java project which is a source-to-source compiler. It translates Java files with jQuery blocks into Java-only files. It accepts a file from the cli arguments, transpiles it and outputs the result to a new file. I used ANTLR for this.
Now that the program is working, I would like to make some sort of plugin which makes use of it. Just like we can create a new Java project, code and run the program in eclipse, I would like to be able to create a new JavaWithJQuery project, be able to code, and when I run it with eclipse, it would use the project I made to transpile it and run it directly, instead of outputting a file with Java-only.
Is this possible? I would appreciate some tips, and advice on how to get started.
Thanks in advance! :)
I'm a noobie to Java and I had some questions, I think they may be easy (duh) answers to you experts but for me, I couldn't figure out the answer.
What is the point of Java programs, all I am making in my class now are simple read text files, have user input some stuff on the command line and the program prints out something. Like, it's cool and all that I can make a program do this but what does this all lead up to?
Say, I create a java program that converts celcius to fahrenheit and I want to have someone use it. Would I be able to get someone to use it that has no knowledge of Java, that is to say, giving it to my mom and she can run it from her computer without using Eclipse? How do I have someone who has no knowledge of coding run my program?
And my last question is, what is the point of command line arguments? Instead of putting them in the arguments, why not just have it in the code itself? Is it because if the code is big, it might be hard to find it? And if I download code that requires argument input, is it possible to download the code with the arguments set in Eclipse or would I have to manually do it?
Thanks, sorry for the long paragraph, but just wanted to put my thoughts down.
I think the short answer is modularity. Compiling or building a Java program takes time and knowledge (like you mentioned, someone who has no knowledge of Java probably wouldn't know what to do).
Passing in command line arguments allows you to just send someone the binary distribution of your program and passing in their own parameters without having to know what your code looks like or have to modify it.
In real life, programs aren't run from Eclipse (obviously), they're usually packaged into jars or wars and executed from the command line or some kind of app server.
If you download code that requires command line arguments, you will probably have to put them into Eclipse yourself, but hopefully the application has some documentation or help usage that explains what the arguments should look like.
You can create your own jar files that you can run from the console.
One of the simpliest ways to make your program usable without using Eclipse is with the Windows command prompt or Linux terminal:
go to you working directory (where your java file is stored)
Type javac (Example:javac hello.java) -This would compile your program
Type java (Example: java hello) - This will start it
Using of args is when you want to set some information to your program with the launching of the program.
Another way to start your program without using Eclipse is to make your own executable jar. With this you will get something like .exe file From which you can start your aplication
Most of the java programs are started from the CMD / terminal, or runs on java servers. There are aplication which have their own user interface (SWING, SWT, AWT ...) .
Most popular types of Java usage is creating a serious bussiness software, android aplications, complex web aplications etc.
what is the point of command line arguments?
Benefits of using Command line.
if I download code that requires argument input, is it possible to
download the code with the arguments set in Eclipse or would I have to
manually do it?
Right Click on project-name > Run > Run Configuration > select Arguments tab
For more info click here.
What is the point of Java programs, all I am making in my class now
are simple read text files, have user input some stuff on the command
line and the program prints out something. Like, it's cool and all
that I can make a program do this but what does this all lead up to?
This is just the begining. Learn Java core. Get familiarized with Java. One day you will be building tools using Java. eg:- Apache
How do I have someone who has no knowledge of coding run my program?
Compiling a java program into an executable
Before you do any this, get a book on Java (my fav - Java The Complete Reference) and read it. Learn how Java works, why is it different from other languages, best practices etc...
After 2-3 years from now, you'll get the importance of taking a small step by building simple cmd line programs using Java
I want to use the Clear Parser for extract semantic role label of the input sentence. I downloaded the jar file here but I don't know how to use this jar file.
I search on the web but there isn't good guideline for using it.
Please help me to solve this problem (My project is in eclipse on windows).
Mind that Clearparser is now ClearNLP. For an idea how to use the ClearNLP API, check out the DemoNLPDecoder linked from their project page. In fact, that's a small runnable application to which you pass all the models as command line arguments, along with an input and a output file.
I stumbled upon the need to find out (inside Java code) which files are dynamically loaded by an SWF-file. Is there any possibility to get a list of paths of every object referenced inside?
I tried out some libraries without proper documentation and gave up. Although I ran out of Google Search Phrases... ;)
Maybe there is an external tool which can be accessed by Java via command line?
Ggreat thanks in advance
Maybe you can get to the information you need using the dump tool which is part of Apparat.
I use actionscript more than Java, so I also recommend having a look at AS3SWF which is a great library you could use to load and analyze the swf you need. Think of it as decompiling at runtime.
Either way, the SWF Format Specifications will come in handy.
I'm not sure there's something that does exactly what you want, but I imagine you could collect all the strings (DefineText tags), loop through them and run an URL RegEx against them.
I think even if you could analyze a SWF file, you can't be sure to get this information. I have Flex Project (finally a swf file) which dynamically loads some modules, but the names (URLs) of the available modules are requested from the server. So there is no chance to retrieve this information from the main swf file.
Hey i am hoping to write a program where the program automatically just copy pastes all my dad's documents from D:\office folder. So whenever I plug-in my pen-drive , the program silently copies all documents inside my pen-drive. Also all files should be pasted to a hidden folder in the pen-drive (so it remains private) . Synchronization capability also required ...So which language should be easy and where to get started ...any idea ??.
Seems to me that some spyin' is about to be goin' on here. :P
I'd recommend C++. Not extremely easy as .Net's tillyvally but fast, framework independent, convenient to manipulate Windows API. You wanna do advanced stealth app, you can't pick the easy way.
Why use the clipboard when you could just use shell commands???
Maybe write an autostart batch file on your pen drive that copies files to/from your flash drive as needed.
I infer you are on Windows. Window has a plethora of functions to manipulate files. A few functions are below.
CopyFile Copies an existing file to a new file.
FindFirstFile Searches a directory for a file or subdirectory name that matches a specified name.
FindFirstFileEx Searches a directory for a file or subdirectory name and attributes that match those that are specified.
FindNextFile Continues a file search.
MoveFile Moves an existing file or directory and its children.
On and on. These and many more functions are documented here.
File Management Functions
Copy or move the files to the pen drive.
HTH
I hate to be the person who suggests this (I don't like .NET that much):
Make a C# (or VB if you must) Console app, or Forms app (if you want to get fancy). The .NET framework will make this kind of program VERY easy and it might be fun. Unless you want to increase your proficiency in C/C++, i would suggest NOT doing it in those languages since there is a learning curve and it is a little complex to do some simple things.
"Just paste" or "synchronize"?
For synchronization, unison is a good bet, see http://en.wikipedia.org/wiki/Unison_(file_synchronizer). For "just paste", you could code a call to a batch calling XCOPY from with the Windows Autoplay mechanism.
Sounds like a secret covert operation you're talking about, though...
I think that you will need to do a lot of work to get a less than satisfactory result.
I would suggestion you instead have a look at DropBox, which is free up to 2Gb of storage which automatically synchronizes between all registered computers, plus has a special folder which allows for web access. Very nice.
I would suggest to use Camel framework of Java, there you can easily run service which will for example automatically copy data from your flash disk after plug in, to folder which you specify etc.
Good tutorial how to start is here:
https://www.youtube.com/watch?v=dmtXkA7FlwA