I want to transform my clauses to conjuctive normal form. Clauses are changed each time i run my program, so i guess i need to built-in a tool in my program to do this for me. Is there any suggestionn how to implement this?? i also found some libraries like:
Orbital library. I am new to logic programming and i have never used them so, its quite difficult to get through them. I also tried to find an example to clear things up, but nothing came up. I am builting my program in java language. Please help...
Thanks in advance!
can you use some of this code?
http://aima-java.googlecode.com/svn/trunk/aima-core/src/main/java/aima/core/logic/fol/CNFConverter.java
# Non-members may check out a read-only working copy anonymously over HTTP.
svn checkout http://aima-java.googlecode.com/svn/trunk/ aima-java-read-only
Related
due to reasons I am working with undocumented java library code that I cannot alter in any way or write into. Im using eclipse 2020-06 and I would like to leaves some notes for myself to make things easier. Is there a way to do that? or maybe an eclipse extension?
You can use bookmarks. They work somewhat similarly to breakpoints, without pausing execution when you're debugging.
You can add them via the context menu.
If I recall, you're a bit limited by the amount of information you can add. It's basically just a single text box.
See the help section on bookmarks
Maybe there's some plugins which extend the functionality (e.g. this one for adding keyboard shortcuts)
I am going to need the ability to programmatically modify Java source code, specifically apply refactorings. For example moving a method from one class to another, changing an access modifier from public to private, etc.
Now in C# I'd probably go the abstract syntax tree / Roslyn approach, but I have no idea where to even begin in Java.
Given a java source code file, how does one parse it so that modifications can be made and then saved to it?
First: Things like that (called refactoring) are already handled by a good Java IDE (Eclipse, IntelliJ IDEA, NetBeans and you name it). I really think that stuff like that should be handled by an IDE.
Second: If you really want to edit the files programmatically keep in mind that you're the one who is in charge of format and syntax. You have to read the files, edit them (cut out, paste in or add some code at proper line) and save them. The link provided from VedX is a good start for basic IO. But there is so much more to keep track of.
I did something similar with OpenEdge ABL and it is no easy task (you'll find things that went wrong you never thought of and if you didn't backed up your code it's f**ked up). I've got it done but in the end it wasn't a good trade-off between time spend to get it done and actual usefullness (I just needed it about 4 times for approx. 1500 files).
Finally (after I lost many hours inventing the wheel of refactoring) I wrote some class generators which wrote a whole new file evertime I needed to change something - lastly I only changed the class generators (maybe this is something you didn't thought of and it fits too). Now it's automatized and generic and could run in parallel (something what OpenEdge isn't designed for - okay it's a cheap hack by me).
Third: Maybe there is a package you can use in your Java project. I would try to Google it. My first attempt resulted in this: http://www.methodsandtools.com/archive/archive.php?id=4 for first understanding what it's all about and what to consider.
I've been having terrible luck trying to get this to work, so I'm hopeful someone can help here.
In Java, I need to be able to take an HTML page with JavaScript within it and detect any JavaScript errors without, preferably without executing the JavaScript code.
I found this article:
Javascript parser for Java
And I've attempted to figure out how I'm supposed to use Caja to do this, but I'm having a difficult time finding any documentation with working examples of anything close to what I'm doing.
As a result I took a look at Nashorn also referenced in that article. I found a few examples which show how to execute JavaScript code from Java, but this doesn't process the whole HTML page. Even then, the execution doesn't seem to include the ability to validate common JavaScript functions (e.g. It hadn't heard of "alert").
Can anyone recommend something that might be able to do what I want, and point me in the right direction for their documentation or give me an example?
jshint as a standalone product seems to be a good fit for this:
it can run in java inside rhino (see https://github.com/jshint/jshint/)
a nodejs package exists (see https://www.npmjs.com/package/jshint)
it works with nashorn but it's quite tricky
I will only cover the technical difficulties around 3rd solution as I finally managed to make it work too...
Spoiler alert: "alert()" is not detected yet... Solution nb 2 will help there...
You first need to grab this specific release of jshint: https://github.com/jshint/jshint/releases/tag/2.4.4
Anything later than v2.7.0 will fail for now and I personally gave up patching intensively prototypes and namespaces... Releases from v2.4.4 until v2.6.3 work without modification but are limited in functionalities.
In the release notes, it's specifically written that "support for the Nashorn JavaScript engine" is working on this release. I'm using JDK8 nashorn 1.8.0_45 for this test.
Next step is to extract from this release this single file jshint-2.4.4/dist/jshint-rhino.js
Now you need to run nashorn/jjs in scripting mode and you need to be specific about the single file you wish to verify. In solution 2 (nodejs based) you can do multiple files or a complete hierarchy below a folder...
Create a simple file file.js:
function(){}
Now run the following command (please note the presence of -- ):
jjs -scripting jshint-rhino.js -- file.js
This will give you the following output:
Missing name in function declaration. (file.js:1:9)
> function(){}
So this covers the how to run jshint in a simple manner with nashorn... With the 3rd solution, at least you can find missing semicolons and several typical errors. But it's not a silver bullet and to me it's not a real alternative.
My personal preference would be to stick to solution 2 only. If you've the possibility to install either nodejs or iojs on your dev platform, go and grab https://www.npmjs.com/package/jshint. Not only will you be able to do more than the 3rd solution, you'll also be able to configure a jshintrc file as described at http://jshint.com/docs/
So I'm battling an endless chaotic system.
There's a glassfish server which provides several reports from a sql server. I need to find which pages are accessing what tables.
The system is not homogenous, meaning that some pages might have their SQL query directly in the jsp page while others might have a separate DAO.Java file.
I do have the Java sources inside each directory.
My only idea would be to do individual searches for each table I'm looking for, but this will take loads of time... and in the future I'll have to do this again.
Maybe there's a better way? Maybe I could index all lines of code in the server? Any suggestions?
Wow, this is an old question. Maybe it should be closed. But if anyone finds themselves in a similar situation:
Group all source code you have. Got code without source? Decompile it.
Get a *nix system.
Use cat and grep to quickly run through everything.
I've found LINQPad to be extremely useful when answering StackOverflow questions for C# or VB.NET. It allows me to write up some quick code, run it, and (if I want) see a nicely-formatted dump of the results. That way I can be sure that the code I post actually runs. Thus far I haven't seen anything that I can use to achieve the same result with Java. Is there anything like that out there?
I am not looking for something to query data sources; I just want a light-weight IDE. These are the features I'm particularly interested in:
The ability to write and run short snippets of code without establishing a whole project or file structure.
Reporting of compiler and runtime errors in the code when it is run.
The ability to add references to a particular editor instance.
Syntax highlighting and Autocomplete/Intellisense would be a plus.
JPad - A java scratchpad for running snippets
Since I also couldn't find one I've decided to write one. Currently it can:
Run java snippets (no class / imports / public blah... needed).
Contains drivers for MS/MySQL/Postgres.
Output results as HTML tables
It's very rough but I will add to it over time. Feedback is definitely welcome.
This may help : http://www.browxy.com:9000/codeRunner
EDIT: Url seems to have changed to http://www.browxy.com
You can use the Groovy web console ; it's possible to speak java in groovy land.
Java Snippet Runner:
Does something similar to Linqpad (jar file, not just for macs)
http://mac.softpedia.com/get/Development/Java/Java-Snippet-Runner.shtml
Code Runner (Commercial):
for Mac's only, it'll run code snippets in Java, and lots of other languages too (e.g. Objective C)
http://krillapps.com/coderunner/
http://ideone.com is an online service that has the features you want.
I've been using JEdit for a long time, which is a very powerful cross-platform editor, NOT an IDE. It does have plugins to execute Java code right in the editor, and even uses BSH for macros.
I was looking for a "Java LinqPad" also, and i came across :
this
I've been using IntelliJ IDEA and it works really well as a Groovy scratchpad. The Community Edition is free too.
You need to create a new project, but then can add Groovy scripts to it and run them on the fly. Not had any luck with the actual Scratch File functionality though.
Being a Jetbrains editor it's pretty slick too. (Unlike some of the other options)
Nothing beats LinqPad though.