英文:
How to refresh a java application after making a file change
问题
以下是翻译好的内容:
这可能对一些人来说听起来像是一个愚蠢的问题,但我不是一个Java开发者,我们已将一个Java应用从Rackspace服务器迁移到了AWS Linux服务器,并将MySql从5.2.x升级到了5.7.x。一些SQL语句正在引起问题,所以我正在尝试在.java
文件中进行修复。然而,当我保存文件,然后使用VSCode中的.sftp
库将更改推送到Linux服务器,然后刷新站点时,并没有反映出更改。每次进行更改时,我是否还需要做其他的事情?
我能够在一个.jsp
文件中更新一些字符串,并且在我刷新页面时有效,所以我不确定为什么当我更改一个.java
文件时,它不会反映出更改。
整个目录对我来说很混乱,我相信这样做是为了让所有的文件、配置、Tomcat文件等都在一个Git文件夹下,这样它就可以随处放置。我发现很多资料都说会创建一个.war
文件,并将该文件放置在Tomcat应用程序目录中。
以下是该应用程序目录的基本布局:
-www/live/njun
-build.xml
+lib
+scripts
+sql
+src
-tomcat(包含一些配置文件、脚本、webapps文件夹)
-web
-content
-index.jsp
-trampoline
-包含`.java`文件的includes文件夹
-tickets
-ticketsMgr.java(这是我修改的文件,但在应用程序中我看不到任何差异)
-index.jsp(这是我修改的一个文件,在浏览器中有反映出来)
-WEB-INF
-classes/com/njun
-很多包含`.Class`文件的文件夹(尽管当我打开它们时,都是一些乱码字符)
这是我所看到的基本结构。
我尝试去/opt/tomcat/bin
并运行sh startup.sh
来重新启动Tomcat。但那没有起作用。
我还在上述Tomcat文件夹中运行了sh startup.sh version
,显示了一些关于home、base tmpdir、jre_home等信息。但那也没有起作用。
我没有被要求对这个应用程序进行重大修改,我想我可以自己处理SQL错误。如果我们需要对这个应用程序进行增强,我们会雇佣一个Java开发者。
如果我遗漏了什么,请告诉我,我可以提供更多信息。
提前感谢您的帮助,
英文:
This may sounds like a dumb question to some, but I am not a Java developer, we have moved a Java app from Rackspace server to AWS linux server and upgraded MySql from 5.2.x to 5.7.x. Some SQL statements are causing issues so I am trying to fix those inside the .java files. However, when I save the file, and use .sftp library from VSCode to push the changes to the linux server, then refresh the site, it does not reflect the changes. Is there anything else I need to be doing every time I make a change?
I was able to update some string in a .jsp file and that worked when I refreshed, so I am not sure why when I change a .java file, it does not reflect change.
The entire directory is confusing to me, I believe it was done so that all files, configs, tomcat files, etc. would be under one git folder so that it can just be dropped anywhere. I find a lot of sources state that a .war file would be created and you would place that file in the tomcat apps directory.
Here is the basic layout of the directory of the app
-www/live/njun
-build.xml
+lib
+scripts
+sql
+src
-tomcat(has some config files, scripts, webapps folder)
-web
-content
-index.jsp
-trampoline
-includes folders with .java files
-tickets
-ticketsMgr.java (this is the file I modified but I could not see any differences in app)
-index.jsp (this is one I modified and did reflect in browser)
-WEB-INF
-classes/com/njun
-lots of folder that have .Class files(although when I open them it's all gibberish characters)
This is the basic structure of what I am looking at.
I tried going to the /opt/tomcat/bin and > sh startup.sh - to restart tomcat. That didn't work.
I also ran the > sh startup.sh version inside of the tomcat folder above,
/tomcat/bin/sh startup.sh - that shows me some info where the home, base tmpdir, jre_home, etc. But that didn't work neither.
I am not being asked to make major modifications on this app, I figure I can manage the SQL errors myself. If we get to the point where we need enhancements done to this app, we would hire a Java developer.
Please let me know if I am missing something and I can provide.
Thanks in advance,
答案1
得分: 1
这是因为一个 .java 文件只是源代码。您需要编译它并上传在编译 .java 源文件时生成的相应 .class 文件。如何编译和运行 Java 程序。或者,由于它在Tomcat实例上运行,您可能有一个JAR或WAR文件。但是想法仍然是一样的,因为这些基本上只是包含您的 .class 文件(以及其他与您的问题不太相关的内容)的zip文件。
英文:
That's because a .java file is just source code. You need to compile it and upload the corresponding .class file generated when you compile the .java sources. How to compile and run a Java program. Or well, since it runs on a Tomcat instance, you might have a JAR or WAR file. But the idea is still the same, since those are just basically zip files that hold your .class files (among other stuff that's less relevant for your issue).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论