Appending Text To Start of Java Files
Hello,
I have many Java source files, and I want to insert some text to the beginiing of all these files.
Any ideas how I should go about it ?
Btw, the direcrtory structure is such that, there are only Java files, but distributed under many sub directories.
--Steve
On UNIX/Linux this is a piece of cake ...
1. write a shell script that takes a parameter (being your java filename)
2. In script concatenate the standard text file using the cat command (append output to new file)
cat stdText.txt > tmpFile.java
cat $1 >> tmpFile.java
cp tmpFile.java $1
3. At the command prompt using the fabulous unix 'find' command search for all java files in your source tree and on each one execute your script :
find . -name "*.java" -exec myscript {} \;
4. voila
...but your probably on windows ! I'm sure its possible but I have no other clues. Try using the bash shell thing I know as Cygwin. By the way, I have just hacked this together and would suggest backing everything up before you start doing anything...
Similar Messages
-
Starting exetutable java file from java code
Hi I was wondering how I can start a executable java file from java code?
thanksHi Mkaveli,
Yes, it's possible. If you have a JAR executable, you've just to call the main method of its starter class. For a simple executable class, just call its main method.
This way :
SomeStarter.main(null); // if there's no argumentSmall precision : the executable JAR or class must be specified in the classpath of your application. -
Append text in file. and save it
Append text in file.
hi!
i am new j2me Programer.
1.i want to add(APPEND) the text in the file. i take this code form internet but i could succed Please help me.
2.i want to save it in other directory like if i made folder on mobile device with name c:\Old i want to save file in that how could i ?
kindly mention the Mistake.
package FileConnection;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
* @author QTracker
public class FileConnection extends MIDlet implements CommandListener {
private boolean midletPaused = false;
private Command exit, start;
private Display display;
private Form form;
public FileConnection ()
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 1);
start = new Command("Start", Command.EXIT, 1);
form = new Form("Write To File");
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(this);
private void initialize() { }
public void startMIDlet() { }
public void resumeMIDlet() {/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
public Display getDisplay () {
return Display.getDisplay(this);
public void exitMIDlet() {
switchDisplayable (null, null);
destroyApp(true);
notifyDestroyed();
public void startApp() {
display.setCurrent(form);
public void pauseApp() {
midletPaused = true;
public void destroyApp(boolean unconditional) {
public void commandAction(Command c, Displayable d) {
if (c == exit)
destroyApp(false);
notifyDestroyed();
else if (c == start)
try
OutputConnection connection = (OutputConnection)
Connector.open("file:\\c:\\myfile.txt;append=true", Connector.WRITE );
OutputStream out = connection.openOutputStream();
PrintStream output = new PrintStream( out );
output.println( "This is a test." );
out.close();
connection.close();
Alert alert = new Alert("Completed", "Data Written", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
catch( ConnectionNotFoundException error )
Alert alert = new Alert(
"Error", "Cannot access file.", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
catch( IOException error )
Alert alert = new Alert("Error", error.toString(), null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}| Moderator advice: | Please read the announcement(s) at the top of the forum listings and the FAQ linked from every page. They are there for a purpose. |
| | Please don't post in threads that are long dead and don't hijack another poster's thread. |
| | Please don't solicit off forum communication by email. |
| Moderator action: | The other four posts you made have been deleted. |
db -
How can I open in java file a text file?
Hi !
For example I have a java file name Pencil.java and I have a text fie name Box.txt
I want like that if ( a == b ) {open Box.txt}
How can I do that ?
Thanks.Yes I want to see what this text file contains. Like clicking to a text file with mouse and opens. Then I can see what it contains.
I have a Java document Pencil.java and I have a text file Box.txt
I will write a java code in pencil.java ( that I dont know ). Then when I enter a number from keyboard with
Scanner write = new Scanner(System.in);
int a = write.nextInt()
if (a == b) { } opens Box.txt
For example
I write to command prompt
java pencil
It wants from me a number : I will enter 3.
It is same as b .
Then Box.txt file opens.
Edited by: zue on Jun 3, 2008 11:04 AM -
Merge/append the contents of a pdf file to an MS Word document in JAVA
Hi experts,
I have a requirement to merge/append the contents of a pdf file to an ms word document(Not to be done by including pdf file objects in word). Please suggest some java libraries or ways to do it using java. Any pointers would be appreciated.
Regards,
SubinOdonnells52 you will still need to install Adobe Acrobat Professional prior to being able to make edits to PDF or utilize Acrobat. By default the installation files have been saved to your download folder.
If you continue to face difficulties with the Adobe Download Assistant then please see Troubleshoot Adobe Download Assistant.
You can also download the installation files directly from Download Acrobat products | Standard, Pro | XI, X if you are unable to locate the downloaded installation files. -
How can i append text in a text file?
Thanks in advance.FileOutputStream has two constructors which allow appends: FileOutputStream(File file, boolean append)
FileOutputStream(String name, boolean append) -
Is there any way to avoid stop/start of tomcat when a java file is modified
Hi all,
we are developing a tool where we use java files for mediation layer and jsp files for presentation layer. so whenever i do a change in any of my java source i need to stop/start the tomcat in order to get the latest change.
is there any way to avoid this kind of stop/start.... i want the changes to get reflected immediately after i compile the file.hai ,
i wrote a sample test.jsp and TestJava.java file and i tried callin api getValue() in TestJava.java from test.jsp.then i did some modifications to this api i.e., i changed the return type from String to int . then compiled n also touched the file but the changes didn't get reflected instead i got the followin error.
Location: /support/jsp/test.jsp
Internal Servlet Error:
javax.servlet.ServletException: com.adventnet.itm.common.TestJava: method getValue()I not found
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:508)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:475)
Root cause:
java.lang.NoSuchMethodError: com.adventnet.itm.common.TestJava: method getValue()I not found
at jsp._0002fjsp_0002ftest_0002ejsptest_jsp_3._jspService(_0002fjsp_0002ftest_0002ejsptest_jsp_3.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:475)
kindly help me ASAP.......
Tanxxx in advance,
Ani -
Append text through File Connection JSR-075
Hi all and thank you in advance.
Can I append text to a text file which resides in an expansion card? I need the data inside the file to be preserved until I delete the file and the text I enter each time to be writen at the end of the file and stay there.
Any help would be appreciated.| Moderator advice: | Please read the announcement(s) at the top of the forum listings and the FAQ linked from every page. They are there for a purpose. |
| | Please don't post in threads that are long dead and don't hijack another poster's thread. |
| | Please don't solicit off forum communication by email. |
| Moderator action: | The other four posts you made have been deleted. |
db -
Appending string to the start of a file problem
Hi guys,
I've got an xml file which i want to add a dtd to. So i'm using RandomAccessFile to seek the start of the file and write to it, but its seems to be overwriting a small part of my file. My code to this is below:
try {
RandomAccessFile f = new RandomAccessFile(xmlMap,"rw");
f.seek(0);
//write DTD definition to start of file
f.writeChars("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+"\n"+
"<!DOCTYPE map SYSTEM \"mapDTD.dtd\">"+"\n");
f.close();
} catch(IOException e) {
System.out.println("ERROR with file name, game exiting");
System.exit(1);
}If i take in this xml file:
<map width="19" height="19" goal="6" name="Hallways of Dooom">
<random-item type='lantern' amount='5' />
<random-item type='health' amount='10' />
<tile x="0" y="0" type="floor" />
<tile x="1" y="0" type="floor">
<renderhint>floor:wood</renderhint>
</tile>
<tile x="2" y="0" type="floor" />
<tile x="3" y="0" type="wall" />
<tile x="4" y="0" type="wall" />
<tile x="5" y="0" type="wall">
<renderhint>wall:bricks,cracked</renderhint>
</tile>it gets overwritten as :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "mapDTD.dtd">
<tile x="0" y="0" type="floor" />
<tile x="1" y="0" type="floor">
<renderhint>floor:wood</renderhint>
</tile>
<tile x="2" y="0" type="floor" />
<tile x="3" y="0" type="wall" />
<tile x="4" y="0" type="wall" />
<tile x="5" y="0" type="wall">
<renderhint>wall:bricks,cracked</renderhint>
</tile>I want it so it is :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "mapDTD.dtd">
<map width="19" height="19" goal="6" name="Hallways of Dooom">
<random-item type='lantern' amount='5' />
<random-item type='health' amount='10' />
<tile x="0" y="0" type="floor" />
<tile x="1" y="0" type="floor">
<renderhint>floor:wood</renderhint>
</tile>
<tile x="2" y="0" type="floor" />
<tile x="3" y="0" type="wall" />
<tile x="4" y="0" type="wall" />
<tile x="5" y="0" type="wall">
<renderhint>wall:bricks,cracked</renderhint>
</tile>
<tile x="6" y="0" type="wall" />
<tile x="7" y="0" type="wall" />
<tile x="8" y="0" type="wall">
<renderhint>wall:rock,cracked</renderhint>
</tile>If anyone can see what's going wrong and how i can correct, i would greatly appreciate them saying so.
Thanks a lot.javaUser wrote:
Hi guys,
I've got an xml file which i want to add a dtd to. So i'm using RandomAccessFile ...That's your mistake. Don't use random access file. It wasn't built for this situation and shouldn't be used for this situation. Do the right thing: rewrite the whole file. -
Add text in beginning of the file
Dear friends,
i have text file.... that contains some texts... for example file sample.txt contains,,
Java is multithreaded.
Java is robust.
Java is secure.
here i want to add 2 more line at the beginning of file (BOL)... those lines are
Java is easy to learn.
Java is platform-independent.
how can i add those lines at the beginning of file....?
if i use FileWriter.. that will append at the end of the file (EOL)
please give me a clue....!
Thank you,
boss134A strangely appropriate nic.
package forums;
import krc.utilz.io.Filez;
class Prepend
public static void main(String[] args) {
try {
String originalContent = Filez.read("Prepend.orig.txt");
String newContent = Filez.read("Prepend.new.txt");
Filez.write(newContent, "Prepend.orig.txt");
Filez.append(originalContent, "Prepend.orig.txt");
} catch (Exception e) {
e.printStackTrace();
}Cheers. Keith. -
BUG : JDev 10.1.3 SR2 hangs when opening a java files
Hi,
think I've found a bug. I'm using JDev 10.1.3, patched with SR1 & 2, my machine is a Windows XP SP2 box with 1GB mem and Intel Pentium 4 2.60 Ghz with HT.
When I try to open a file in the Java editor the IDE hangs. Launching jdev.exe I can see that the following output is continuously printed:
Exception occurred updating RowMap: 16
startRow: 0
numRows: 1
startLine: 0
numLines: 15
_rowCount: 15
lineCount: 15
Stack trace follows
java.lang.ArrayIndexOutOfBoundsException: 16
at oracle.javatools.buffer.ArrayLineMap.getLineEndOffset(ArrayLineMap.java:326)
at oracle.javatools.editor.BasicView$LineRowMap.recalculateLineWidths(BasicView.java:3576)
at oracle.javatools.editor.BasicView$LineRowMap.recalculateRows(BasicView.java:3487)
at oracle.javatools.editor.BasicView$LineRowMap.handleInsert(BasicView.java:3315)
at oracle.javatools.editor.BasicView$LineRowMap.rebuildRowMap(BasicView.java:3286)
at oracle.javatools.editor.BasicView$LineRowMap.<init>(BasicView.java:3259)
at oracle.javatools.editor.BasicView$FoldedRowMap.<init>(BasicView.java:3966)
at oracle.javatools.editor.BasicView.updateMetrics(BasicView.java:1128)
at oracle.javatools.editor.BasicView.getPreferredSpan(BasicView.java:1730)
at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTextUI.java:1257)
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:819)
at oracle.javatools.editor.BasicEditorUI.getPreferredSize(BasicEditorUI.java:158)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1227)
at javax.swing.JViewport.getViewSize(JViewport.java:1003)
at javax.swing.plaf.basic.BasicScrollPaneUI.syncScrollPaneWithViewport(BasicScrollPaneUI.java:264)
at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.viewportStateChanged(BasicScrollPaneUI.java:855)
at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(BasicScrollPaneUI.java:797)
at javax.swing.JViewport.fireStateChanged(JViewport.java:1357)
at javax.swing.JViewport.setView(JViewport.java:975)
at oracle.ideimpl.editor.SplitPane.setEditorComponent(SplitPane.java:343)
at oracle.ideimpl.editor.SplitPane.attachEditor(SplitPane.java:949)
at oracle.ideimpl.editor.SplitPane.attachCurrentEditor(SplitPane.java:919)
at oracle.ideimpl.editor.SplitPane.setCurrentEditorStatePos(SplitPane.java:1138)
at oracle.ideimpl.editor.SplitPane.setSplitPaneState(SplitPane.java:207)
at oracle.ideimpl.editor.TabGroup.attachCurrentNode(TabGroup.java:517)
at oracle.ideimpl.editor.TabGroup.setCurrentTabGroupState(TabGroup.java:1294)
at oracle.ideimpl.editor.TabGroup.activateEditor(TabGroup.java:639)
at oracle.ideimpl.editor.EditorManagerImpl.createEditor(EditorManagerImpl.java:1273)
at oracle.ideimpl.editor.EditorManagerImpl.createEditor(EditorManagerImpl.java:1196)
at oracle.ideimpl.editor.EditorManagerImpl.openEditor(EditorManagerImpl.java:1131)
at oracle.ideimpl.editor.EditorManagerImpl.whenOpenEditor(EditorManagerImpl.java:2332)
at oracle.ideimpl.editor.EditorManagerImpl.handleDefaultAction(EditorManagerImpl.java:1893)
at oracle.ide.controller.ContextMenu.fireDefaultAction(ContextMenu.java:343)
at oracle.ideimpl.explorer.BaseTreeExplorer.fireDefaultAction(BaseTreeExplorer.java:1504)
at oracle.ideimpl.explorer.BaseTreeExplorer.dblClicked(BaseTreeExplorer.java:1841)
at oracle.ideimpl.explorer.BaseTreeExplorer.mouseReleased(BaseTreeExplorer.java:1862)
at oracle.ideimpl.explorer.CustomTree.processMouseEvent(CustomTree.java:176)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Forcing RowMap rebuild
I also disabled ALL extension and removed the jar files in jdev/extension, except the one that was originally included in the 10.1.3 and those that seems related to the service releases.
The file I'm trying to open is done like this:
--- start after this line ---
package com.websiteitalia.jsftest.view.controllers.people.list;
import com.websiteitalia.jsftest.model.list.people.PeopleListUtil;
import com.websiteitalia.jsftest.view.controllers.BaseListBacker;
import com.websiteitalia.weblib.ejb.list.IWSList;
public class PeopleListBacker extends BaseListBacker {
public IWSList getListRemote() throws Exception {
return PeopleListUtil.getList();
--- end before this line ---
I include also an HEX encoding of the file:
00000000h: 70 61 63 6B 61 67 65 20 63 6F 6D 2E 77 65 62 73 ; package com.webs
00000010h: 69 74 65 69 74 61 6C 69 61 2E 6A 73 66 74 65 73 ; iteitalia.jsftes
00000020h: 74 2E 76 69 65 77 2E 63 6F 6E 74 72 6F 6C 6C 65 ; t.view.controlle
00000030h: 72 73 2E 70 65 6F 70 6C 65 2E 6C 69 73 74 3B 0D ; rs.people.list;.
00000040h: 0A 0D 0A 69 6D 70 6F 72 74 20 63 6F 6D 2E 77 65 ; ...import com.we
00000050h: 62 73 69 74 65 69 74 61 6C 69 61 2E 6A 73 66 74 ; bsiteitalia.jsft
00000060h: 65 73 74 2E 6D 6F 64 65 6C 2E 6C 69 73 74 2E 70 ; est.model.list.p
00000070h: 65 6F 70 6C 65 2E 50 65 6F 70 6C 65 4C 69 73 74 ; eople.PeopleList
00000080h: 55 74 69 6C 3B 0D 0A 69 6D 70 6F 72 74 20 63 6F ; Util;..import co
00000090h: 6D 2E 77 65 62 73 69 74 65 69 74 61 6C 69 61 2E ; m.websiteitalia.
000000a0h: 6A 73 66 74 65 73 74 2E 76 69 65 77 2E 63 6F 6E ; jsftest.view.con
000000b0h: 74 72 6F 6C 6C 65 72 73 2E 42 61 73 65 4C 69 73 ; trollers.BaseLis
000000c0h: 74 42 61 63 6B 65 72 3B 0D 0A 69 6D 70 6F 72 74 ; tBacker;..import
000000d0h: 20 63 6F 6D 2E 77 65 62 73 69 74 65 69 74 61 6C ; com.websiteital
000000e0h: 69 61 2E 77 65 62 6C 69 62 2E 65 6A 62 2E 6C 69 ; ia.weblib.ejb.li
000000f0h: 73 74 2E 49 57 53 4C 69 73 74 3B 0D 0A 0D 0A 0D ; st.IWSList;.....
00000100h: 0A 70 75 62 6C 69 63 20 63 6C 61 73 73 20 50 65 ; .public class Pe
00000110h: 6F 70 6C 65 4C 69 73 74 42 61 63 6B 65 72 20 65 ; opleListBacker e
00000120h: 78 74 65 6E 64 73 20 42 61 73 65 4C 69 73 74 42 ; xtends BaseListB
00000130h: 61 63 6B 65 72 20 7B 0D 0A 20 20 20 20 0D 0A 20 ; acker {.. ..
00000140h: 20 20 20 70 75 62 6C 69 63 20 49 57 53 4C 69 73 ; public IWSLis
00000150h: 74 20 67 65 74 4C 69 73 74 52 65 6D 6F 74 65 28 ; t getListRemote(
00000160h: 29 20 74 68 72 6F 77 73 20 45 78 63 65 70 74 69 ; ) throws Excepti
00000170h: 6F 6E 20 7B 0D 0A 20 20 20 20 20 20 20 20 72 65 ; on {.. re
00000180h: 74 75 72 6E 20 50 65 6F 70 6C 65 4C 69 73 74 55 ; turn PeopleListU
00000190h: 74 69 6C 2E 67 65 74 4C 69 73 74 28 29 3B 0D 0A ; til.getList();..
000001a0h: 20 20 20 20 7D 0D 0A 20 20 20 20 0D 0A 7D 0D 0A ; }.. ..}..
Note the last empty line before the end-of-file. If I try to past this code into a Java file and open it in JDev, it hangs as described.
Moreover, if I remove the last empty line, JDev will open the file in the editor but, as soon as I enter it again (placing the cursor at the end of the file a hitting enter) JDev hangs again.
A final note: I experienced many hangs also in JSP editor, especially selecting a block of text and pasting something in its place, but don't know if the two behaviours are related.Ok, maybe I've tracked down at least one factor that makes JDev hang. I changed my font back to the default "DialogInput" instead of "Lucida Console" and now it opens my file.
This is the settings that works in system/oracle.jdeveloper.10.1.3.36.73/preferences.xml
<Item>
<Key>FontSizeOptions</Key>
<Value class="oracle.ide.ceditor.options.FontSizeOptions">
<fontFamily>DialogInput</fontFamily>
<fontSize>12</fontSize>
<showOnlyFixedWidth>false</showOnlyFixedWidth>
</Value>
</Item>
With this one it hangs:
<Item>
<Key>FontSizeOptions</Key>
<Value class="oracle.ide.ceditor.options.FontSizeOptions">
<fontFamily>Lucida Console</fontFamily>
<fontSize>12</fontSize>
<showOnlyFixedWidth>false</showOnlyFixedWidth>
</Value>
</Item>
Logging the exception
Exception occurred updating RowMap: 16
startRow: 0
numRows: 1
startLine: 0
numLines: 15
_rowCount: 15
lineCount: 15
Stack trace follows
java.lang.ArrayIndexOutOfBoundsException: 16
at oracle.javatools.buffer.ArrayLineMap.getLineEndOffset(ArrayLineMap.java:326)
at oracle.javatools.editor.BasicView$LineRowMap.recalculateLineWidths(BasicView.java:3576)
at oracle.javatools.editor.BasicView$LineRowMap.recalculateRows(BasicView.java:3487)
at oracle.javatools.editor.BasicView$LineRowMap.handleInsert(BasicView.java:3315)
at oracle.javatools.editor.BasicView$LineRowMap.rebuildRowMap(BasicView.java:3286)
at oracle.javatools.editor.BasicView$LineRowMap.<init>(BasicView.java:3259)
at oracle.javatools.editor.BasicView$FoldedRowMap.<init>(BasicView.java:3966)
at oracle.javatools.editor.BasicView.updateMetrics(BasicView.java:1128)
at oracle.javatools.editor.BasicView.getPreferredSpan(BasicView.java:1730)
at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTextUI.java:1257)
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:819)
at oracle.javatools.editor.BasicEditorUI.getPreferredSize(BasicEditorUI.java:158)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1227)
at oracle.javatools.editor.gutter.LineGutterPlugin.getRowCount(LineGutterPlugin.java:1485)
at oracle.javatools.editor.gutter.LineGutterPlugin.getPreferredSize(LineGutterPlugin.java:890)
at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:690)
at java.awt.Container.preferredSize(Container.java:1558)
at java.awt.Container.getPreferredSize(Container.java:1543)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1617)
at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78)
at java.awt.Container.preferredSize(Container.java:1558)
at java.awt.Container.getPreferredSize(Container.java:1543)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1617)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:717)
at java.awt.Container.layout(Container.java:1401)
at java.awt.Container.doLayout(Container.java:1390)
at java.awt.Container.validateTree(Container.java:1473)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validate(Container.java:1448)
at java.awt.Window.show(Window.java:515)
at oracle.ideimpl.MainWindowImpl.show(MainWindowImpl.java:572)
at java.awt.Component.show(Component.java:1300)
at java.awt.Component.setVisible(Component.java:1253)
at oracle.ideimpl.MainWindowImpl$2.runImpl(MainWindowImpl.java:773)
at oracle.javatools.util.SwingClosure$1Closure.run(SwingClosure.java:50)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Forcing RowMap rebuild -
Problem compiling a simple java file
Hi,
When I try to compile the following simple java file
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HowdyServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<html>");
out.println("<body>");
out.println("<center><h1>Hi</h1></center>");
out.println("</body>");
out.println("</html>");
at the command prompt as follows
C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac -classpath
"C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip" *.java
Or
C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac *.java
Or
C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac HowdyServlet.java
I get the following errors and I cannot compile this java file -
HowdyServlet.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
HowdyServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HowdyServlet.java:5: cannot find symbol
symbol: class HttpServlet
public class HowdyServlet extends HttpServlet {
^
HowdyServlet.java:6: cannot find symbol
symbol : class HttpServletRequest
location: class HowdyServlet
public void doGet(HttpServletRequest request,
^
HowdyServlet.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class HowdyServlet
HttpServletResponse response)
^
HowdyServlet.java:8: cannot find symbol
symbol : class ServletException
location: class HowdyServlet
throws IOException, ServletException {
^
6 errors
I have installed the latest JEE 5 SDK on Win XP Home. I have the following variable set as follows,
CLASSPATH = .;C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip
PATH = C:\Sun\AppServer\jdk\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\QuickTime\QTSystem;C:\Sun\AppServer\lib\ant\bin
ANT_HOME = C:\Sun\AppServer\lib\ant
I have spent hours scratching my head but don?t have a clue. I was wondering if you have any idea as why I might be getting these errors.
Thank you for your time.
GreenHello, did you read the answers?
You have to put j2ee.jar or servlet-api.jar in your classpath. Those JAR files are included in the Java EE package somewhere. Remove the QTJava.zip junk from the classpath.
If you don't know what the classpath is and how to set it, read this:
Setting the class path
How Classes are Found
And I'll repeat what the others say: if you are very new to Java, then Java EE will probably be way over your head. First learn the language and the standard API. If you understand that well, start with Java EE. Or do you already know what servlets are, and that you need a servlet container to run them, and how to deploy them etc.? -
JFileChooser problem opening just java files
Hi everyone, trying to write simple text ed. that will only open java files (part of JFileChooser). Yes have looked at API but so stupid that i couldnt get it to work can anyone help?
public void openFile() {
BufferedReader in = null;
try {
JFileChooser chooser = new JFileChooser();
//---Open Java Files only---
if (chooser.showOpenDialog(null)
== JFileChooser.APPROVE_OPTION) {
File selectedFile = chooser.getSelectedFile();
in = new BufferedReader
(new FileReader(selectedFile));
catch(FileNotFoundException e) {
JOptionPane.showMessageDialog
(null, "Bad Filename. Try Again");
catch(IOException e) {
JOptionPane.showMessageDialog
(null, "Corrupted File. Try Again");
finally {
if (in != null)
try {
StringBuffer buffer = new StringBuffer();
String text = new String();
text_chat.setText(text + "\n\n");
while((text=in.readLine())!=null)
buffer.append(text+ "\n");
text_chat.setText(buffer.toString());
catch(IOException e) {
JOptionPane.showMessageDialog
(null, "Error closing File.");
}Can you tell me how did you solve the problem? Right now I am encounter ing the same problem. The java files on JFileChooser did not show up!
-
Does anyone know if it's possible to open a java file from a c# web form?
Any links would also be appreciated,
Thanks,
ClivertI don't know anything about C# web forms (that's pretty far away from the topic of this forum) but I expect anybody answering the question would need to know what you mean by "open" and "a java file" in that context.
For example it might mean to cause a text editor to run and display the source code for a Java class. Or it might mean for a Java JVM to start running and execute the main method of a Java class. -
I am trying to use java file as Model layer and jsf as presentation layer
I am trying to use java file as Model layer and jsf as presentation layer and need some help
I successfully get the value of h:outputText from java file by doing simple binding operation but I am facing problems when I am trying to fill h:dataTable
I create java file
package oracle.model;
import java.sql.;*
import java.util.;*
*public class TableBean {*
Connection con ;
Statement ps;
ResultSet rs;
private List perInfoAll = new ArrayList();
*public List getperInfoAll() {*
perInfoAll.add(0,new perInfo("name","username","blablabla"));
return perInfoAll;
*public class perInfo {*
String uname;
String firstName;
String lastName;
*public perInfo(String firstName,String lastName,String uname) {*
this.uname = uname;
this.firstName = firstName;
this.lastName = lastName;
*public String getUname() {*
return uname;
*public String getFirstName() {*
return firstName;
*public String getLastName() {*
return lastName;
right click on the file and choose 'create data control'
then i wrote the jsf file:
*<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>*
*<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>*
*<f:view>*
*<h:dataTable id="dt1" value="#{bindings.perInfoAll}"*
var="item" bgcolor="#F1F1F1" border="10"
cellpadding="5" cellspacing="3" rows="4" width="50%"
dir="LTR" frame="hsides" rules="all"
*>*
*<f:facet name="header">*
*<h:outputText value="This is 'dataTable' demo" id="ot6"/>*
*</f:facet>*
*<h:column id="c2">*
*<f:facet name="header">*
*<h:outputText value="First Name" id="ot1"/>*
*</f:facet>*
*<h:outputText style="" value="#{item.firstName}"*
id="ot2"/>
*</h:column>*
*<h:column id="c4">*
*<f:facet name="header">*
*<h:outputText value="Last Name" id="ot9"/>*
*</f:facet>*
*<h:outputText value="#{item.lastName}" id="ot8"/>*
*</h:column>*
*<h:column id="c3">*
*<f:facet name="header">*
*<h:outputText value="Username" id="ot7"/>*
*</f:facet>*
*<h:outputText value="#{item.uname}" id="ot4"/>*
*</h:column>*
*<f:facet name="footer">*
*<h:outputText value="The End" id="ot3"/>*
*</f:facet>*
*</h:dataTable>*
*</center>*
*</af:document>*
*</f:view>*
but nothing is appear in my table
I know that there is something wrong in calling the binding object
I need help pls and where can i find some help to deal with another tag types
thanksi dragged the "perInfoAll" from my "Data Controls" and choosed adf table (even I know that new table with adf tags well be generated and i want table with jsf tags)
and this code is generated
*<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"*
*"http://www.w3.org/TR/html4/loose.dtd">*
*<%@ page contentType="text/html;charset=UTF-8"%>*
*<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>*
*<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>*
*<%@ taglib uri="http://xmlns.oracle.com/adf/faces/rich" prefix="af"%>*
*<f:view>*
*<af:document id="d1">*
*<af:messages id="m1"/>*
*<af:form id="f1">*
*<af:table value="#{bindings.perInfoAll1.collectionModel}" var="row"*
*rows="#{bindings.perInfoAll1.rangeSize}"*
*emptyText="#{bindings.perInfoAll1.viewable ? 'No data to display.' : 'Access Denied.'}"*
*fetchSize="#{bindings.perInfoAll1.rangeSize}"*
*rowBandingInterval="0"*
*selectionListener="#{bindings.perInfoAll1.collectionModel.makeCurrent}"*
*rowSelection="multiple" id="t1">*
*<af:column sortProperty="uname" sortable="false"*
*headerText="#{bindings.perInfoAll1.hints.uname.label}"*
*id="c1">*
*<af:inputText value="#{row.bindings.uname.inputValue}"*
*label="#{bindings.perInfoAll1.hints.uname.label}"*
*required="#{bindings.perInfoAll1.hints.uname.mandatory}"*
*columns="#{bindings.perInfoAll1.hints.uname.displayWidth}"*
*maximumLength="#{bindings.perInfoAll1.hints.uname.precision}"*
*shortDesc="#{bindings.perInfoAll1.hints.uname.tooltip}"*
*id="it3">*
*<f:validator binding="#{row.bindings.uname.validator}"/>*
*</af:inputText>*
*</af:column>*
*<af:column sortProperty="firstName" sortable="false"*
*headerText="#{bindings.perInfoAll1.hints.firstName.label}"*
*id="c2">*
*<af:inputText value="#{row.bindings.firstName.inputValue}"*
*label="#{bindings.perInfoAll1.hints.firstName.label}"*
*required="#{bindings.perInfoAll1.hints.firstName.mandatory}"*
*columns="#{bindings.perInfoAll1.hints.firstName.displayWidth}"*
*maximumLength="#{bindings.perInfoAll1.hints.firstName.precision}"*
*shortDesc="#{bindings.perInfoAll1.hints.firstName.tooltip}"*
*id="it2">*
*<f:validator binding="#{row.bindings.firstName.validator}"/>*
*</af:inputText>*
*</af:column>*
*<af:column sortProperty="lastName" sortable="false"*
*headerText="#{bindings.perInfoAll1.hints.lastName.label}"*
*id="c3">*
*<af:inputText value="#{row.bindings.lastName.inputValue}"*
*label="#{bindings.perInfoAll1.hints.lastName.label}"*
*required="#{bindings.perInfoAll1.hints.lastName.mandatory}"*
*columns="#{bindings.perInfoAll1.hints.lastName.displayWidth}"*
*maximumLength="#{bindings.perInfoAll1.hints.lastName.precision}"*
*shortDesc="#{bindings.perInfoAll1.hints.lastName.tooltip}"*
*id="it1">*
*<f:validator binding="#{row.bindings.lastName.validator}"/>*
*</af:inputText>*
*</af:column>*
*</af:table>*
*</af:form>*
*</af:document>*
*</f:view>*
but when run it i see the following errors
*Class oracle.adf.model.adapter.bean.BeanDataControl can not access a member of class nl.amis.hrm.EmpManager with modifiers "private"*
*Object EmpManager of type DataControl is not found.*
*java.lang.NullPointerException*
*Class oracle.adf.model.adapter.bean.BeanDataControl can not access a member of class nl.amis.hrm.EmpManager with modifiers "private"*
*Object EmpManager of type DataControl is not found.*
*java.lang.NullPointerException*
:(
Maybe you are looking for
-
Lately I have been receiving images as attachments coming through as only around 30-50 kb. I need the full sized images, but people tell me they have sent them as large images. Is there some way my mail program could be downsizing them on receipt, or
-
I need to show details about messages transactions. I decided to use a Stacked Bar chart to view present number of trans' of different types by their date. I use this query in all the series: select null link, sd label, c value from (select trunc(STA
-
I want to create a formula in numbers that gives me an ongoing monthly average
I've created a spreadsheet to track my MPG, and I'm also logging all maintenance bills too. What I want to do, is get an idea of how much the vehicle is costing me on a monthly average. I want this to be ongoing over several years and therefore want
-
How to install package's man page
Hi all! I'm the maintainer of pcsx2-svn in AUR and currently the installation process doesn't install the man page automatically. In the source code I have a "pcsx2.man" file, that I'm gzipping and moving to the correct man folder. See command: gzip
-
Hi anyone & all, Iam using this files for FMS testing. Sample file which iam using now Everything is working fine, but i need some more features. (i) when published i need to play the first flv in the list. (ii) when i click next button it should ski