954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Beginner using Java... Having trouble with javac and creation of .class files.

I will simply provide my .bat file in hopes that someone can guide me in the right direction. I have been given several tips and hints, but no one has been able to walk me through this and considering I have never even touched Java before I have no idea what I'm doing. I primarily use c++ and vb. Here is the .bat file I am trying to compile.

<code>
&lt;pre&gt;&lt;code&gt;&amp;quot;C:\JAVA\bin\javac.exe&amp;quot; &amp;quot;C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\Constants.java&amp;quot;

&amp;quot;C:\JAVA\bin\javac.exe&amp;quot; &amp;quot;C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\NetComm.java&amp;quot;

&amp;quot;C:\JAVA\bin\javac.exe&amp;quot; &amp;quot;C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_ClientGui.java&amp;quot;

&amp;quot;C:\JAVA\bin\javac.exe&amp;quot; &amp;quot;C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_GThread.java&amp;quot;

&amp;quot;C:\JAVA\bin\javac.exe&amp;quot; &amp;quot;C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_GsmMain.java&amp;quot;

&amp;quot;C:\JAVA\bin\jar.exe&amp;quot; cf &amp;quot;C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Client.jar&amp;quot; &amp;quot;C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\Constants.class&amp;quot; NetComm.class srvr_ClientGui$1.class srvr_ClientGui$2.class srvr_ClientGui$3.class srvr_ClientGui$4.class srvr_ClientGui$5.class srvr_ClientGui$RadioListener.class srvr_ClientGui.class srvr_GThread.class srvr_GsmMain$1.class srvr_GsmMain.class srvr_GThread.class

&amp;quot;C:\JAVA\bin\jar.exe&amp;quot; umf &amp;quot;C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_ClientJarText&amp;quot; &amp;quot;C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Client.jar&amp;quot;&lt;/code&gt;&lt;/pre&gt;</code>
bumassjp
Newbie Poster
17 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

Have those been compiled yet? If it is looking for the physical class files, those are not created until after the java program has been compiled.

no1zson
Posting Whiz in Training
226 posts since Jul 2007
Reputation Points: 59
Solved Threads: 1
 
Have those been compiled yet? If it is looking for the physical class files, those are not created until after the java program has been compiled.


No they haven't... I didn't write these files just so you know I got them from our parent company, but they are garbage... I think after looking at the files that I am trying to compile the actual files are bad. I keep bringing up tons of errors. Java is a pain... lol

bumassjp
Newbie Poster
17 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

It is definatley not for the faint of heart.
I have only been using it for about a month now, and if it were not for the guys out here I think I would have eaten a bullet by now!

no1zson
Posting Whiz in Training
226 posts since Jul 2007
Reputation Points: 59
Solved Threads: 1
 

You don't mention what problem you are having with the batch file - but I am thinking it's probably a class path issue. Are you getting things like "No class def found" ?

javac needs to know the class path to find any other classes that your java file is using. This can be specified with the -cp option for the javac command or it can be set via the CLASSPATH environment variable. Here is some more info on that:
http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

If you got that batch file from another source, you might see if there is another file like "setEnv.bat" in the directory, which sets the environment classpath. If so, run that one first.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 
If you got that batch file from another source, you might see if there is another file like "setEnv.bat" in the directory, which sets the environment classpath. If so, run that one first.


I appreciate the help, but that is not what it is. I'm getting errors from the commands in the files im calling in the batch file. I have basically concluded that the place I got these from is worthless...

bumassjp
Newbie Poster
17 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 
I appreciate the help, but that is not what it is. I'm getting errors from the commands in the files im calling in the batch file. I have basically concluded that the place I got these from is worthless...


Again, you don't state what the specific errors are. If you posted some of them it might help.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

Or u can do one thing

go to start->run->cmd
u will come to dos prompt
type cd\[enter]
then type set P[Enter]
After this u will c the path i suppose ur javec path is not set
so u set by using following command
if u installed in c:\ with name jdk1.4
then
set PATH=c:\jdk1.4\bin;c:\jdk1.4\lib;c:\jdk1.4\jre\bin;jdk1.4\jre\lib%PATH%[Enter]
after that whenever u want to compile the programs u have to go initially c:\jdk1.4\bin
then save that file in that folder and 
run javac filename.java
java filename


Hope that would help.....

Ved_TheOne
Newbie Poster
16 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

This is basically what im getting when I try to run the batch file in cprompt.


C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14>"C:\JAV
A\bin\jar.exe" cf "C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Serv
er_Client14\srvr_Client.jar" "C:\Users\smartparts\Documents\POWERTRAK\Java Sourc
e Code\Server_Client14\Constants.class" "C:\Users\smartparts\Documents\POWERTRAK
\Java Source Code\Server_Client14\NetComm.class" "C:\Users\smartparts\Documents\
POWERTRAK\Java Source Code\Server_Client14\srvr_ClientGui$1.class" "C:\Users\sma
rtparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_ClientGui$2.cl
ass" "C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\s
rvr_ClientGui$3.class" "C:\Users\smartparts\Documents\POWERTRAK\Java Source Code
\Server_Client14\srvr_ClientGui$4.class" "C:\Users\smartparts\Documents\POWERTRA
K\Java Source Code\Server_Client14\srvr_ClientGui$5.class" "C:\Users\smartparts\
Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_ClientGui$RadioListene
r.class" "C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client
14\srvr_ClientGui.class" "C:\Users\smartparts\Documents\POWERTRAK\Java Source Co
de\Server_Client14\srvr_GThread.class" "C:\Users\smartparts\Documents\POWERTRAK\
Java Source Code\Server_Client14\srvr_GsmMain$1.class" "C:\Users\smartparts\Docu
ments\POWERTRAK\Java Source Code\Server_Client14\srvr_GsmMain.class" "C:\Users\s
martparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_GThread.clas
s"
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\NetComm
.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Cl
ientGui$1.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Cl
ientGui$2.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Cl
ientGui$3.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Cl
ientGui$4.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Cl
ientGui$5.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Cl
ientGui$RadioListener.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Cl
ientGui.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_GT
hread.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Gs
mMain$1.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_Gs
mMain.class : no such file or directory
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14\srvr_GT
hread.class : no such file or directory

C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14>"C:\JAV
A\bin\jar.exe" umf "C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Ser
ver_Client14\srvr_Client.jar" "C:\Users\smartparts\Documents\POWERTRAK\Java Sour
ce Code\Server_Client14\srvr_ClientJarText"
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:393)
at java.util.jar.Manifest.read(Manifest.java:182)
at java.util.jar.Manifest.(Manifest.java:52)
at sun.tools.jar.Main.update(Main.java:530)
at sun.tools.jar.Main.run(Main.java:184)
at sun.tools.jar.Main.main(Main.java:1022)
C:\Users\smartparts\Documents\POWERTRAK\Java Source Code\Server_Client14>


basically it is not making any class files.

bumassjp
Newbie Poster
17 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

Well, I assume that is only part of the batch file, or you are supposed to run another batch before that one, because it is trying to create a jar file from classes that aren't there. Do you have any docs for this POWERTRAK stuff or is it an internal app?

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

OK thanks for all the help guys, but i figured it out... all in all I'm retarted. lol I had the class files being saved to the c:\java dir but trying to be called from my users dir. again thanks for the help and sorry I'm such a nublet...

bumassjp
Newbie Poster
17 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You