How should I display my code inside of my Java program? - java

I apologize if this question is too "general";
But my question is very specific to what I am programming and I was not able to find a descent answer anywhere else.
I am creating a "Proof of Concept" program for extra credit in my calc class.
Now that the program is finished, I want to make a way to view the coding of the program to show the teacher and explain what I did.
My first thought was to use a JTextPane, but how would that work?
I want to find some way to display all the lines of coding, keeping the structure of coding that Java/Eclipse uses.
What is the best way to do this?
Thanks,
-Steven

use system.out.println and get a free account at https://github.com/ and upload your code and the output of your programs . Send the link to your professor ..I think he will be impressed not only by your work but also by how you are presenting your code to him/her to review it.
good luck, I am already impressed that you are searching online to best present your work for that you deserve an A+ too. keep up the good work.

If I was your teacher, I'd prefer to be shown your code within an IDE (such as Eclipse). Then I could browse around as I pleased and see it execute in front of me.
IDEs are built for looking at code :-)

I am preferring you to use your IDE , but anyway :
Maybe i am wrong but I think the only way is to get the codes from the (.java) file
and copy it to TextArea but it's not perfect like your IDE.
I will not post the whole program just the function hope it will be useful for you
Scanner sc = null;
try{
sc=new Scanner(new File("yourProgram.java"));
}catch(Exception ex){System.out.println(ex.getMessage());}
String line = "";
while (sc.hasNextLine()){
jTextArea1.append(line=sc.nextLine()+"\n");
}

Related

How to write the whole code regarding wrapping text around image

Im trying to implement 'wrap text around image' but I'd rather write it step by step on my own so I can understand it fully.
Can somebody tell me how to do so? Any websites worth recommending regarding this issue?
I think FlowTextView is exactly what you need.

How to replace a few specific lines of code stemming from com.sun.image.codec.jpeg.*

I am just getting into 3D modeling, like really just getting into it.
JPEGImageEncoder jie = JPEGCodec.createJPEGEncoder(bos);
JPEGEncodeParam param = jie.getDefaultJPEGEncodeParam(bImage);
param.setQuality(1.0f, true);
jie.setJPEGEncodeParam(param);
jie.encode(bImage);
I need to replace these lines, apparently with java ImageIO.
I really don't know much about these, but I would like to get this code to run.
I got the code from here:
http://www.java2s.com/Code/Java/3D/HumanAnimation.htm
I was able to find all the packages I needed, but it won't let me use some of the sun packages. From what I've read, I should be using java ImageIO to do these things, but the problem is, I'm not sure what these lines are doing exactly, so I don't know what to replace them with. Any help would be great. Thanks.

deeplearning4j generate response to input

I have recently been trying to learn DL4J but have run into some issues. They have an example of a neural network generating Shakespeare-like text based off and input character but I can't seem to find anything that wold indicate a possible way of creating a response to an input statement.
I would like to use an input string such as "Hello" and have it be able to generate a response of varying length depended on the input. I would like to know if this is possible using LSTM and have a point in the right direction as I have no idea where to even start.
We have plenty of documentation this actually. This gives you a layout of what an RNN looks like:
http://deeplearning4j.org/usingrnns
The model you would be looking at is character level, in general what you want is question answering though. You may want to look at an architecture like this: https://cs.umd.edu/~miyyer/pubs/2014_qb_rnn.pdf
If you are completely new to NLP, I would look at this class:
https://www.youtube.com/playlist?list=PLhVhwi0Pz282aSA2uZX4jR3SkF3BKyMOK
It covers question answering as well.

How does minecraft and runescape validate your chat?"

Basically, what I am asking is, how does a java based program with free chat gaurd against, "); String onlinejava = "exploits by closing the string."
Pretty simple: they don't need to. Java is a compiler-language, thus the code can't be modified by this kind of exploits. This can only be done in some interpreter-languages, or before the code is compiled, like in SQL.

call lucene method with php

i have problem calling lucene method in php.
im beginner in java.
n im searching in google 4 solving, but no found.
im trying write this java code to php using php java bridge.
http://www.lucenetutorial.com/lucene-in-5-minutes.html
i found this line that i dont get it how to make it to php:
IndexReader reader = DirectoryReader.open(index);
DirectoryReader has no 'new' for initial a object, that's what i dont get it to write in php.
but, if the java code like below,
Query q = new QueryParser(Version.LUCENE_43, "content", analyzer).parse(querystr);
i write like this:
$query = new Query\QueryParser($version->LUCENE_43,'content',$analyzer);
$query->parse($strquery);
n no error.
so, how to create this java code
IndexReader reader = DirectoryReader.open(index);
to php ??
really need help,
thanks a lot in advance.
You should be able to use Zend's Zend_Search_Lucene module rather than using the PHP-Java bridge directly. Check it out it may be much more easier.
Can you reference to where you read that it'd be slower? What measurements were taken and how was this done? I am not really sure that, whatever these performance implications, they'd have a noticeable impact on our application.
Also since you're using Symfony there are ready libraries that provide integration for Symfony and Symfony2. I really suggest using Zend Search Lucene especially if you don't have JAVA experience since basing your application on more than one technology is already complex enough.
Another useful thing that may come in handy is a Lucene/Sorl query builder. I know that I am not answering your exact technical question however being a PHP programmer and having experience with Sorl/Lucene I just wanted to point out the issues above so that you can take the appropriate decision.

Categories